Attached is a screenshot of the LV example VI. If you don't use LV, then just pay attention to the triangles drawn out on the bottom.
We can calculate the distance from the target using a couple known values and some trigonometry. We know the camera's resolution, its field of view (the angle at which it can view, or 2Θ), and the width of the target in real life, and the target's position in the camera image. Here's a comment from the VI that goes over the math:
Quote:
Since we know that the target width is 2', we can use its pixel width to determine the width
of the camera field of view in ft at that working distance from the camera. W is half of that.
Divide by the tangent of theta (half the view angle), to determine d.
|
So we take the width of the target box in pixals, and determine the width of the whole image (2/width*xresolution/2). Then, we can divide that by the tangent of .5Θ (where Θ = the view angle, as found on the Axis camera
datasheet [about 47˚ for the M1011, and 54˚ for the 206]) to get the distance in feet.
Also, all this is explained in
NI's Whitepaper on the subject