I have a point in image space p1 = (u1, v1) where u and v are the pixel coordinates. I project this point out in to 3D coordinates, using the projection matrix of the camera, to intersect with a plane that is parallel to the image plane. Let us call this projected 3D point P1 = (x1, y1, z1).
Now I want to project a second point p2 = (u1 + d, v1) -- the new point only changes in the horizontal pixel coordinate i.e. u1 + d where d is a finite value in pixels. However, I want to find the value of d for which its projected point P2 = (x2, y2, z2) is a particular distance away from P1 in world coordinates.
For example, lets say I want P2 to be 1 meter away from P1, how do I pick the right value for u1 + d?
I can incrementally keep projecting different values of d until I get the right distance, but there should be a way to backcalculate this? I scanned opencv functions and couldn't find something that did this
Thank you.
I don’t know how you can possibly project a 2D point back to 3D, but let’s ignore that problem, for the time being.
Take the projection ray through the point $p_2$ and intersect it with a sphere of radius 1 meter centered at $P_1$. If you’re lucky, there will be two intersection points, and either one of them will serve as the point $P_2$ that you’re seeking.