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
    Commented Jan 12, 2013 at 23:24
  • $\begingroup$ I have these measurements, I don't know what to do next. $\endgroup$
    – Belos
    Commented Jan 12, 2013 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
    Commented Jan 12, 2013 at 23:42

1 Answer 1

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
    Commented Jan 13, 2013 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
    Commented Jan 13, 2013 at 9:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .