I have some experience from last year converting a target location in pixels to an offset in degrees using the FOV of the camera, but I am not sure how to apply that to this year’s vision challenge. We are looking to align with the gear peg laterally using vision. Is there a similar equation for converting pixels to translational distance? (Distance we need to slide laterally to get lined up with the peg)

You’ll need to know the distance to the target to make it work.

Pretend the above is a top view of the camera. O is the lens. Y1 is the camera sensor. y1 is the number of pixels off center you are. f is the focal length of the camera. Those are all known locations & values.

So this is a simple similar triangle calculation, if you just know x3.

The problem is that all the pixels along the green line outside of the camera will show up at the same point Q on the sensor. So without knowing the distance x3 you can’t figure out how big x1 is (P could be at any point along the green line).

If you can determine distance x3 some other way (ultrasonic, some trig using the distance between the two vision targets) x1 is easy. But any error in x3 will also be an error in x1 so testing is in order.

In order to compute the translational distance, you will need to know how far away from the target you are. Assuming you can compute the distance, one way to compute the translational movement needed would be like this: compute the angle offset in degrees the way you did last year, compute the distance, then use some trigonometry to calculate the “translational distance” (tan(theta) = translation / distance)

If you’re asking what I think you’re asking, use the **height **of the retroreflective area. Its actual height 5". Divide that by the number of pixels of its height, and you have a good estimate of the image resolution in a direction perpendicular to a (presumably horizontal) camera, and can roughly calculate range.

Alternately, just measure the height in pixels (P0) at a known range R0 (say 10 feet). Then whenever you’re looking at the target, R = R0 * P0 / P. Should be close enough to get you going, but it breaks down as you get close to the target and the sine of the angle is no longer proportional to the angle.