code frame different to count people
Show older comments
Hi
i try to write code in matlab using this paper "https://www.researchgate.net/publication/234710128_Counting_of_People_in_the_Extremely_Dense_Crowd_using_Genetic_Algorithm_and_Blobs_Counting
but not gave me results any one can help me??
%%% First-iteration background frame
background_frame = double(I*0);
redbackground_frame = background_frame(:,:,1);
greenbackground_frame = background_frame(:,:,2);
bluebackground_frame = background_frame(:,:,3);
i=0;
for k = 1:100:nf-1 %get background
thisframe = double(read(v, k))/ 255;
%background_frame = background_frame + thisframe;
redbackground_frame = redbackground_frame + thisframe(:,:,1);
greenbackground_frame = greenbackground_frame + thisframe(:,:,2);
bluebackground_frame = bluebackground_frame + thisframe(:,:,3);
i=i+1;
% disp(i);
% Frames = imadd(read(vob, k),read(vob, k+1));
end
A = redbackground_frame/i;
B = greenbackground_frame/i;
C = bluebackground_frame/i;
background = cat(3,A,B,C);
figure,
imshow(background);
y = medfilt2(rgb2gray(I));figure,
imshow(y);title 'med filter' ;
lastfram=read(v,nf);
Z = imsubtract(rgb2gray(I),rgb2gray(I2));
%Z = imsubtract(rgb2gray(read(v,200)),rgb2gray(lastfram));
%Z=I-background;
figure;imshow(Z);title 'deferent' ;
%-------------------------------------------------------------------
%Idiff=rgb2gray(I2)-rgb2gray(background);
%figure,
%imshow(Idiff);title 'deferent2img' ;
%%%%%%%%%%%%%%%%
binaryImage = imbinarize(Z);
binaryImage = bwareafilt(binaryImage, 1);
labeledImage1 = bwlabel(binaryImage);
props = regionprops(labeledImage1, 'BoundingBox');
hold on;
hRect = rectangle('Position', props.BoundingBox);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
BIdiff=imbinarize(Z);
figure,
imshow(BIdiff);title 'deferentBw' ;
CC = bwconncomp(BIdiff);
%BW2 = bwareafilt(BW,8);
%BIdiff1=imbinarize(Idiff,'adaptive');
%figure,
%imshow(BW2);title 'deferent coonect' ;
binaryImage = bwareafilt(BIdiff, 1);
labeledImage = bwlabel(BIdiff);
%[rl, cl] = find(labeledImage==1);
%rc = [rl cl];
blobMeasurements = regionprops(CC,'all');
props = regionprops(labeledImage, 'BoundingBox');
%figure;imshow(props.BoundingBox);title 'deferent coonect' ;
%hRect = rectangle('Position', props.BoundingBox);
numberOfmoving = size(blobMeasurements, 1)% count the number of people
3 Comments
Walter Roberson
on 31 Oct 2019
What is I in
background_frame = double(I*0);
? And in
thisframe = double(read(v, k))/ 255;
is v a VideoReader object ?
hajer jon
on 31 Oct 2019
Walter Roberson
on 1 Nov 2019
I think it would help to have a short sample video to test with. You can zip one and attach it, as long as the zip is 5 megabytes or less.
Answers (0)
Categories
Find more on Video Formats and Interfaces in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!