Ask Your Question
0

Drawing trajectory of moving object

asked 2017-01-12 11:02:11 -0600

bloodkid gravatar image

Hi! I have a question about making a trajectory of moving object. It would by easy if camera is attached and can't move, but what about drawing trajectory when camera is following an object? I have to do tilt&pan camera with drawing trajectory of moving object. In tilt&pan the camera is always trying to have an object in center, so i can't draw trajectory by using coordinates. Camera is following an object so i have no idea how to do it. I have got camera attached to 2 servos (X axis and Y axis) and a program to follow an object. How to draw trajectory of an object while camera is moving? Have you any ideas? Please reply. Best regards, Patryk.

edit retag flag offensive close merge delete

Comments

so, question rephrased, might be: "how do i seperate camera & object movement" ?

berak gravatar imageberak ( 2017-01-13 02:23:03 -0600 )edit

1 answer

Sort by » oldest newest most voted
0

answered 2017-01-12 11:58:38 -0600

kbarni gravatar image

You need to know the field of view (FOV) of the camera; the rest is simple.

Let's say, the vertical FOV is 40° and the horizontal and vertical resolution is 200px. That means an angular resolution of 5 pixels/degree.

The object is at (X=100,Y=110) pixels in moment T, that means 2° below the center. You move the camera 3° downwards in moment T+1, and the object is at (100,105) (1° below the center). That means, you have to draw a line from (100,105) (actual position) to (100,95) (the old position + the 3°movement).

The easiest way to implement this is to add at each iteration the position of the object to a vector, then change every element in the vector by the movement of the camera X angular resolution. Then draw the polyline over the image.

edit flag offensive delete link more

Comments

But when the object is moving constantly? For example as a sinusoid, so the program will see only beginning and the end so will draw straight line. Am I wrong? Can you show me and example of code?

bloodkid gravatar imagebloodkid ( 2017-01-12 12:12:47 -0600 )edit

Even if the object and the camera are moving continuously, you'll only have its position in discrete moments (the acquisition frequency of the camera).

If you want a smoother trajectory, you can draw a Bezier spline instead of a polyline.

kbarni gravatar imagekbarni ( 2017-01-13 03:11:10 -0600 )edit

kbarni can you write an example code? I do not know how to do it.

bloodkid gravatar imagebloodkid ( 2017-01-16 11:29:15 -0600 )edit
1

Read the FAQ: Please do not beg for code, instead try some tutorials and tell us what is going wrong.

I'm here to help you, but I don't have time to write code instead of you!

kbarni gravatar imagekbarni ( 2017-01-17 05:01:38 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-01-12 11:02:11 -0600

Seen: 2,058 times

Last updated: Jan 12 '17