How to calculate distance from camera using Opencv APIs

Hi,

Is there any Opencv APIs or image processing algorithms in Opencv that can be used to calculate the distance of the camera from the target.

Thanks,
Vijay

Hi!

Depending on your opencv code this is very possible. The way we do vision processing we do blob detection of a particular target (biggest blob always is the one targeted). After we find the blob we draw a circle around it, and place a dot in the center of the circle. For pose correction we use the pixel coordinates of the dot that we draw. Something else we do get from the code is the radius of the circle that we drew. As the camera gets farther away from the target, the target gets smaller, and so does the circle that we drew around the blob. By taking a couple of measurements, you can just create a linear relationship between radius of the circle and real world distance. The calculation actually holds up pretty well, as we plan to use it for targeting this year.

-Cinnamon Toast.
P.S. PM me if you want some sample code with opencv and stuff. I’d be willing to help.