How to track object after detection? ( Done detection using CascadeObjectDetector)

2 views (last 30 days)
I have trained cascade object detector for detecting fist, now I want to track its centroid but cant find a way out. Here is the code of whatever i have done so far.
%code
vidDevice = imaq.VideoDevice('winvideo', 1, 'YUY2_640x480', ...
'ROI', [1 1 640 480], ...
'ReturnedColorSpace', 'rgb');
% Input Video from current adapter
hVideoIn = vision.VideoPlayer('Name', 'Final Video', ...
'Position', [60+vidInfo.MaxWidth 100 vidInfo.MaxWidth+20 vidInfo.MaxHeight+30]);
vidInfo = imaqhwinfo(vidDevice);
numFrame=200;
nFrame = 0;
detector = vision.CascadeObjectDetector('fist1.xml');
while (nFrame < numFrame)
videoFrame = step(vidDevice); % Acquire single frame
bbox = step(detector, videoFrame);
videoFrame = insertShape(videoFrame, 'Rectangle', bbox);
numFrame=numFrame+1;
step(hVideoIn,videoFrame);
end
release(vidDevice);
clc;

Answers (1)

Dima Lisin
Dima Lisin on 8 Feb 2015
There several ways you can do this. One is tracking the centroid using the Kalman filter. You can do that by modifying the Multiple Object Tracking example. You would need to re-write the detectObjects function of the example to use vision.CascadeObjectDetector instead of detecting moving objects using vision.ForegroundDetector.
A different approach would be to track multiple points within the object using the KLT (Kanade-Lucas-Tomasi) algorithm. You can try using the Detect and Track Multiple Faces example on the file exchange.

Community Treasure Hunt

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

Start Hunting!