code frame different to count people

1 次查看(过去 30 天)
Hi
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 个评论
hajer jon
hajer jon 2019-10-31
yes
I is an image wich frame of video
v is video reader object
Walter Roberson
Walter Roberson 2019-11-1
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.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 3-D Volumetric Image Processing 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by