|
Re: how to find distance using two color servo camera?
Here's what Team 533 did to get distance from the camera:
We started with the 2 color tracker sample project supplied by FIRST.
Once we got the tracker working, the top level VI for the 2-color camera code displayed some calculated parameters including "percentage of area".
This number is the ratio of the size of the target as seen by the camera divided by the area of the camera's entire field of view. The farther away the target, the smaller this ratio is. The percentage of area ratio is approximately proportional to the reciprocal of the square of the distance. So distance is approximately proportional to the reciprocal of the square root of the "percentage of area" value:
DISTANCE = K / SQRT(% OF AREA)
(there is a more exact relationship that involves trigonometric functions but the above simple approximation is good enough to judge distances to within a few inches)
We placed the target exactly 4 feet away from the camera and measured the % of area value, then solved for K:
K = (4 feet) * SQRT(Measured % of area when target is at 4 feet).
Next we programmed the formula DISTANCE = K / SQRT(% OF AREA) with the
K value we measured and added an indicator to the fromt panel.
Finally, we tested the revised code at various distances. Since the equation is only an approximation, there is some error but we were able to obtain distance measurements within a few inches using this method.
Neil
Advisor, Team 533
|