Calculate distance between two lines from foreshortened image

544 Views Asked by At

I am trying to calculate the distance between a line on a plane and a line on an object from an image. The goal being to determine how many millimeters the object is from being aligned with the marking. Here's what the image would essentially look like if taken from directly above:

Image_90degree

My problem is that in real life, the object is 3D and the camera is not mounted at 90 degrees to the surface, so it actually looks more like this:

image_perspective

I have the ability to find the lines via computer vision, and I know the dimensions of the object and the parameters of the camera including the focal length and mounting angle. I just have no idea how to compensate for the perspective and thickness of the object.

1

There are 1 best solutions below

0
On

enter image description here

Let's consider the case of the perfect pinhole camera. If you are sure about parallelness of your lines, you can construct “infinity points” for each axis of your brick and then construct invisible points $D$ and $E$. Then you construct a point $G$ on a brick, where the mark will go. Finally, you use cross-ratio theorem:

$$ \frac{QG\cdot EA}{QA\cdot EG} = \left(\frac{EA}{EG}\right)_{\text{in real world}}. $$

// If some axis is represented by truly parallel lines and there is no infinity point, you just draw them parallel instead of going through the infinity point. Of course, you want to take multiple measurements on different lines to average and minimize errors.