We are looking for the complete code to calculate the distance from the camera to the light…

Thanks in advance.

We are looking for the complete code to calculate the distance from the camera to the light…

Thanks in advance.

http://www.chiefdelphi.com/forums/showthread.php?t=44105&highlight=camera+distance

Specifically

The camera center to target center formula is similar:

camera to target angle = target pixel * (camera fov angle / camera pixels) - center pixel

Then combine:

bot to target angle = bot to camera angle + camera to target angle

This might also be helplful, but it is about how to calculate the angle to which one should fire.

http://www.chiefdelphi.com/forums/showthread.php?t=41363&page=1&pp=15&highlight=camera+distance

Then once you have an accurate tilt angle from the camera to the target it is normal trig (tangent) to use that angle and the vertical height between the camera and the target center.

The article Windward quoted I do not believe has any example code with it. I certainly never went that far since our team isn’t using the enhanced accuracy values.

We had a nice Distance_Function() in our program using the tan function and everything, but we found it to not be necessary, since it correlates directly to the tilt_angle so we mapped out distances using the tilt angle as a primary source of measure, works the same, it’s just much simpler.