FIRST Robotics Competition Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Calculating target distance at an angle.

It's pretty easy to track rectangles and calculate their distance from the camera when it's directly ahead, however when the camera angle changes, the rectangle gets distorted. For a while, it is still detected as a rectangle (albeit a distorted one) until the angle increases too much. During this distortion, the distance values returned are understandably skewed. How may one get around this issue?

0 Kudos
Message 1 of 2
(4,064 Views)

Hey demeter,

One way I could think of to do it is to do some geometry based on where the rectangle shows up in the cameras field of view. Since you know the height of the camera on the robot, and the height of the target, and there is a linear (relatively) relationship between how close the camera is to the target and its position vertically in the camera frame you can figure out how far away you are from the target by the targets position in the y axis.

Depending on how the rectangle is distorting you may also be able to find a relationship between the angle of the distorted sides and distance.  There may be a better way but these are what I would look at first.

Kevin Fort
Principal Software Engineer
NI
0 Kudos
Message 2 of 2
(2,551 Views)