1 | initial version |
To draw the trajectory, you need the position of the camera at each time. Using rvec and tvec, you can get this by the following. I'm assuming rvec is the 3x1 rotation angles and tvec is the 1x3 translation.
Rodrigues(rvec, R);
R = R.t();
t = (-R * tvec);
t now contains the camera coordinates relative to the origin of your coordinate system. Now, if your coordinate origin remains the same from frame to frame, you're done.
I haven't had a chance to read everything at the link, but I suspect the origin changes to center on the camera with each frame. If so, you need to add each t to a total you keep that is the total translation from the first frame.
Is that all of what you were wanting to know?
2 | No.2 Revision |
To draw the trajectory, you need the position of the camera at each time. Using rvec and tvec, you can get this by the following. I'm assuming rvec is the 3x1 rotation angles and tvec is the 1x3 translation.
Rodrigues(rvec, R);
R = R.t();
t = (-R * tvec);
t now contains the camera coordinates relative to the origin of your coordinate system. Now, if your coordinate origin remains the same from frame to frame, you're done.
I haven't had a chance to read everything at the link, but I suspect the origin changes to center on the camera with each frame. If so, you need to add each t to a total you keep that is the total translation from the first frame.
EDIT: Ok, I did read the link, and it is the motion from frame to frame. I should also point out that the direction changes from frame to frame, so you need to chain rotation matrices together to get the direction too.
Is that all of what you were wanting to know?