Tracking moving object using KLT
9 views (last 30 days)
Show older comments
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
0 Comments
Answers (1)
See Also
Categories
Find more on Tracking and Motion Estimation 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!