How to draw trajectory line from detected object

4 visualizaciones (últimos 30 días)
Leona Chan
Leona Chan el 8 de Oct. de 2017
Comentada: Leona Chan el 10 de Oct. de 2017
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.

Respuesta aceptada

Image Analyst
Image Analyst el 8 de Oct. de 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 comentarios
Image Analyst
Image Analyst el 8 de Oct. de 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);
Leona Chan
Leona Chan el 10 de Oct. de 2017
Done, thank you very much

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Tracking and Motion Estimation en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by