5
$\begingroup$

I have a 640x480 camera that recognizes a rectangle that is 1ftx2ft. Is it possible to calculate the distance between the camera and the rectangle?

Edit:

The horizontal angle of view is 54°.

$\endgroup$
3
  • $\begingroup$ You will need to know the field of view of the camera and how many pixels wide the rectangle appears in order to calculate the distance away. $\endgroup$ – Shard Jan 12 '13 at 23:24
  • $\begingroup$ I have these measurements, I don't know what to do next. $\endgroup$ – Belos Jan 12 '13 at 23:29
  • $\begingroup$ Knowing the field of view you can calculate how far away the rectangle would have to be to completely fill the view with trigonometry. $\endgroup$ – Shard Jan 12 '13 at 23:42
3
$\begingroup$

$$D=\frac{Lw}{2x\tan\frac\alpha2}$$ where $D$ = Distance from Camera, $L$ = length of object (2ft), $w$=width of screen in pixels (640), $x$=width of object on camera in pixels, and $\alpha$ = camera field of view.

$\endgroup$
2
  • $\begingroup$ Is it assumed that the rectangle is in the center of the screen or it doesn't matter? $\endgroup$ – Belos Jan 13 '13 at 0:31
  • $\begingroup$ With a narrow field of view it shouldn't matter where the rectangle is. But it is important that the rectangle is facing flat on to the camera. If you had been using a wide angle lens things might be trickier. $\endgroup$ – Shard Jan 13 '13 at 9:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.