How do I calculate the distance between an object and the camera?

I know the size of the of the object (in this case the Frisbee targets) and I’m using the Axis M1011 camera.

EDIT: In VBScript. (to put into RoboRealm)

Have you read the vision whitepaper?

How do I calculate tan theta from the camera’s output?

2*theta is the field of view of the camera you are using. You should be able to find that value in the datasheet for the camera.

So… tan(FOV/2) = w/d

If you look at the VBScript code you’ll actually see the answer already in there. In the current case the code will calculate the distance between the camera and a 12" high target. Instead, you’d want to know the width of the frisbee (since the height would be distorted by perspective) and base the distance on that. For example, have a look at the attached code/image as an example.

Note, we’re note sure of the width of the frisbee (I think its 10") so you may need to change that in the VBScript.

Also, note that this is the diagonal distance from the camera to the frisbee … this is NOT the floor distance which will be shorter. But if you know the angle of the camera to the floor you can use a different geometry to figure out that distance.

STeven. (259 KB) (259 KB)