Clear Filters
Clear Filters

How to put a bounding box over a human silhouette figure?

3 views (last 30 days)
I have used foreground detector to extract the human silhouette and used H,S channels of HSV to get shadow free silhouette. How to put a bounding box over it so that i can track the human?
foregroundDetector = vision.ForegroundDetector('NumGaussians',3,'NumTrainingFrames',10,'LearningRate',0.000001);
foregroundDetector1 = vision.ForegroundDetector('NumGaussians',3,'NumTrainingFrames',10,'LearningRate',0.000001,'InitialVariance',(30/255)^2);
vid = videoinput('winvideo', 1); %select input device
i=1;
DlgH = figure('units','normalized','outerposition',[0 0 1 1]);
H = uicontrol('Style', 'PushButton', ...
'String', 'Close', ...
'Callback', 'delete(gcbf)');
while (ishandle(H))
frame = getsnapshot(vid);
subplot(1,3,1), imshow(frame);
title('frame');
foreground = step(foregroundDetector, frame);
%imshow(foreground);
hsv = rgb2hsv(frame);
hsfore = step(foregroundDetector1, hsv(:,:,1:2));
se = strel('square', 3);
filteredForeground = imopen(foreground, se);
HsfilteredForeground = imopen(hsfore, se);
Res = imdilate (HsfilteredForeground,ones(5));
re = imfill(Res,'holes');
subplot(1,3,3), imshow(re);
title('HS foreground Without shadow');
subplot(1,3,2), imshow(filteredForeground);
title('RGB Foreground');
drawnow
end
close

Answers (1)

Image Analyst
Image Analyst on 3 Oct 2017
Use the rectangle() function:
hold on
rectangle('Position', [xLeft, yTop, width, height]);

Categories

Find more on Vehicle Scenarios 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!