I have been researching methods to detect people only in the video from a security camera. I want to use vision.peopledetector with vision.BlobAnalysis and vision.ForegroundDetector. But it doesn't work.
It should be like Motion-Based Multiple Object Tracking example, but only for detecting humans. Cant seem to get it work.
What I have done so far without using vision.BlobAnalysis and `vision.ForegroundDetector. It is not accurate at all and cant count
video = VideoReader('atrium.mp4');
peopleDetector = vision.PeopleDetector;
videoPlayer = vision.VideoPlayer;
while hasFrame(video)
img = readFrame(video);
[bboxes,scores] = step(peopleDetector,img);
D = 1;
frame = insertObjectAnnotation(img,'rectangle',bboxes,D);
step(videoPlayer,frame);
end
OK. So here's what I think is happening: the resolution of the atrium.mp4 video is not high enough to make reliable detections using
vision.PeopleDetector. Here's what I did to modify your code:I now see fairly consistent detections in the video, but they are still not tracked all the time, and there seems to be some erroneous detections (one, specifically at the right bottom corner of the video). To avoid these issues, I would do something like what this demo does:
https://www.mathworks.com/help/vision/examples/track-face-raspberry-pi2.html
In essence, this demo uses face detection only when there are no detections, and switches over to tracking once a detection has been made. That way, your processing loop is significantly faster (tracking is less computationally demanding than detection), and you can have (in general) higher fidelity tracking than independent detections in each frame. You could also include some other heuristics such as no movements at all in > 50 frames implies a false positive, and such.