How to classify the human postures of sitting and standing from video input?

조회 수: 1 (최근 30일)
Avinash S
Avinash S 2016년 3월 5일
편집: Avinash S 2016년 3월 5일
Currently i have done human detection on input from webcam. It puts a rectangle bounding box around the person and the centroid of the box is shown too. How to proceed further to detect the sitting and standing posture?
vid = videoinput('winvideo', 1);
for i=1:10
misc = getsnapshot(vid);
end
bg = misc;
X = im2double(misc);
misc = (X(:,:,1)+X(:,:,2)+X(:,:,3));
misc(misc==0) = 0.001;
X(:,:,1) = X(:,:,1)./misc;
X(:,:,2) = X(:,:,2)./misc;
DlgH = figure('units','normalized','outerposition',[0 0 1 1]);
H = uicontrol('Style', 'PushButton', ...
'String', 'Close', ...
'Callback', 'delete(gcbf)');
while (ishandle(H))
mov = getsnapshot(vid);
subplot(1,2,1), imshow(mov); %1. show current frame%
title('Current Frame');
X1 = im2double(mov);
misc = (X1(:,:,1)+X1(:,:,2)+X1(:,:,3));
misc(misc==0) = 0.001;
X1(:,:,1) = X1(:,:,1)./misc;
X1(:,:,2) = X1(:,:,2)./misc;
A = imabsdiff (X,X1);
A (A<0.27) = 0; %threshold for background subtraction figure 2%
A (A>=0.27) = 1;
Res = imdilate (A,ones(9));
GX = rgb2gray(bg);
GX1 = rgb2gray(mov);
FD = im2double(imabsdiff(GX,GX1));
%subplot(2,2,2), imshow(FD); %2. show foreground%
title('Foreground');
FD(FD<(0.10)) = 0; %threshold for figure 3%
FD(FD>=(0.10)) = 1;
DR = imdilate(FD,ones(9));
re = imfill(DR,'holes');
finalRes(:,:,1) = Res(:,:,1).*re;
finalRes(:,:,2) = Res(:,:,2).*re;
finalRes(:,:,3) = Res(:,:,3).*re;
%subplot(2,2,3), imshow(finalRes); %3. show processed foreground%
title('Foreground2');
boundaries = bwboundaries(rgb2gray(imclose(finalRes,ones(3))));
bndrSize = size(boundaries);
% subplot(2,2,1:2)
subplot(1,2,2), imshow(mov); %4. show final frame%
title('Human detection');
hold on
for k = 1:bndrSize(1)
bnd = boundaries{k};
RB2 = max(bnd);
LT2 = min(bnd);
w = RB2(2)-LT2(2);
h = RB2(1)-LT2(1);
x1 = LT2(2);
y1 = LT2(1);
x2 = LT2(2)+w;
y2 = LT2(1)+h;
x3 = (x1 +x2)/2;
y3 = (y1 + y2)/2;
if (max(RB2-LT2)>100) %with rectangle over them. adjust this to cover only large objects, small values will cover smaller objects %
rectangle('Position',[LT2(2),LT2(1),RB2(2)-LT2(2),RB2(1)-LT2(1)],'EdgeColor','g','LineWidth',1);
rectangle('Position',[x3,y3,10,10],'EdgeColor','r','LineWidth',1);
end
end
end
close

답변 (0개)

카테고리

Help CenterFile Exchange에서 System Identification Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by