Im working on tracking the human silhouette with input from webcam. I have used vision.foregroundDetector to get the foreground masks. But they detect the shadows too. How to eliminate them? Code:
foregroundDetector = vision.ForegroundDetector('NumGaussians',3,'NumTrainingFrames',10,'LearningRate',0.000001); vid = videoinput('winvideo', 1); %select input device
i=1;while(1) %frame = step(vid); % read the next video frame
frame = getsnapshot(vid); foreground = step(foregroundDetector, frame); se = strel('square', 3); filteredForeground = imopen(foreground, se); fname = sprintf('frames/frame%d.jpg',i); imwrite(filteredForeground,fname,'jpg'); i = i+1;end
Output Frame:
Best Answer