Tracking moving object using KLT

9 views (last 30 days)
Breezy Boo
Breezy Boo on 14 Apr 2017
Answered: Mohamed Ata on 27 Apr 2018
Following is code to track corner points using klt algorithm.
I detect corner points using harris corner detector which also include some background points but i want to track only moving objects in the video and place box around them. Can i use blob and gaussian mixture model?
videoFileReader = vision.VideoFileReader('CrowdVideo.avi'));
videoPlayer = vision.VideoPlayer('Position',[100,100,680,520]);
release(videoFileReader);
release(videoPlayer);
objectFrame = step(videoFileReader);
%Detect interest points in the object region
%for rgb image
points = detectHarrisFeatures(rgb2gray(objectFrame));
%Display the detected points
pointImage = insertMarker(objectFrame, points.Location, '+', 'Color', 'white');
figure;
imshow(pointImage);
title('Detected Interest points');
%Creater tracker object
tracker = vision.PointTracker('MaxBidirectionalError',1);
%Initialize tracker
initialize(tracker, points.Location, objectFrame);
%read, track, display point and results in each frame
while ~isDone(videoFileReader)
frame = step(videoFileReader);
[points, validity] = step(tracker, frame);
out = insertMarker(frame, points(validity,:),'+');
step(videoPlayer, out);
end
release(videoPlayer);
release(videoFileReader);
end

Answers (1)

Mohamed Ata
Mohamed Ata on 27 Apr 2018
yes, blob analysis is the best way for your purpose

Community Treasure Hunt

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

Start Hunting!