I think I understand what you mean - you want to calculate how wide the image is in real units?
If you know the angle of the field of view f and the distance to the target d , you can calculate the width w plane visible at this distance with a small number of triggers.
<------------------w--------------------> ***************************************** * ^ * <-----o------> * * | * * * | * * * | * * * | * * * | * * * | * * * d * * * | * * * | * * * | * * * | * * * | * f/2 * * | * * * | * * * v * * * * * * * * *** *
So, remember the old school SOH CAH TOA? tan(angle) = opposite / adjacent . We want to calculate the opposite dimension o , and we know that it is adjacent d , and the angle is f/2 , so we get o = tan(f/2) * d
o is half the width, so we double it to give the final calculation w = d * tan(f/2) * 2
So, now you know the real-time width w units of measurement of the plane d from the camera, and you know that your image is p pixels wide, a pixel per unit is just p/w
The only problem that remains is to calculate the field of view angle f from the focal length of the lens - which is a bit more specialized. It depends on the camera, in particular on the size of the image sensor. You can create a chart for many popular cameras here http://www.howardedin.com/articles/fov.html .
If you know the size of the image sensor or use film negatives of 36 mm x 24 mm, you can use this formula to calculate the FOV for a βnormalβ rectilinear lens:
fieldOfView = 2 * arctan (sensorWidth / (2 * focalLength))
source share