Closed NatalyaSlepkova closed 5 years ago
How I understand reading your code,
Hopefully, it wasn't too hard to understand. I hope to refactor with a focus on improving readability when I get the time.
you build trajectories of video frames use only dx and dy (i.e. H[0, 2] and H[1, 2]).
The elements of trajectory are built using the vidstab_utils.estimate_partial_transform()
helper function which is just a convenience wrapper of cv2.estimateRigidTransform()
1. This helper returns [dx, dy, da]
; where da = np.arctan2(H[1, 0], H[0, 0])
and dx
& dy
are as you described.
I try to build trajectory of frames using his center point (x, y). So new uniform coordinates of this point in next frame are p' = H * (x, y, 1)^T. And then Euclidean coordinates are (p'[0] / p'[2], p'[1] / p'[2]). But so I get very strange plots. Could you explain me, please, where my mistake?
Could you provide example code or example input-output of what you're doing? It would be very helpful in understanding the issue.
1 cv2.estimateRigidTransform()
is used if using OpenCV version < 4.0.0. This function was deprecated as of OpenCV 4.0.0 in favor of cv2.estimateAffinePartial2D()
(which is used in vidstab if using 4.0.0)
You could see code https://github.com/NatalyaSlepkova/VideoTrajectories TrajectoriesCenterPoint.py is code, stable.avi is example video, centersPlot.png is plot for this video - you could see it in README
Thanks for your project! How I understand reading your code, you build trajectories of video frames use only dx and dy (i.e. H[0, 2] and H[1, 2]). I try to build trajectory of frames using his center point (x, y). So new uniform coordinates of this point in next frame are p' = H * (x, y, 1)^T. And then Euclidean coordinates are (p'[0] / p'[2], p'[1] / p'[2]). But so I get very strange plots. Could you explain me, please, where my mistake?