How to draw trajectory line from detected object

4 views (last 30 days)
How can I draw the trajectory line on detected object from video? The object will move from fig1.jpg position to fig2.jpg position. How can I get the red point position and draw the trajectory line? Would you please help, thanks.

Accepted Answer

Image Analyst
Image Analyst on 8 Oct 2017
I would think that plot should be able to do it:
hold on;
plot([x1,x2], [y1,y2], 'r-', 'LineWidth', 2);
You just need to use the x and y that you used to draw the red spots, which you should already have since I see them in your images.
  3 Comments
Image Analyst
Image Analyst on 8 Oct 2017
Not exactly where the red spot should go, but I think you can erode the binary image until the "shaft" is gone and all that's there is the "head" of the golf club. Then get the centroid.
binaryImage = imerode(binaryImage, true(3)); % Get rid of shaft.
binaryImage = bwareafilt(binaryImage, 1); % Take only the largest remaining blob.
props = regionprops(binaryImage, 'Centroid'); % Find centroid of blob.
x = props.Centroid(1);
y = props.Centroid(2);

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!