[Math] Calculate distance to person from camera if camera is on the floor

computer visiongeometrylinear algebratrigonometry

Below is a diagram of the setup. Using a smartphone camera, placed on the floor, I'd like to know how to figure out person's height, Y.

Since I know how far off the floor the camera is and the angle the camera is at, I know i & j.

I can't figure out what trig I need to figure out the triangle that is either the distance from the camera to the person's feet or the triangle formed by the person on the camera sensor.

Without using any reference points in the image (e.g. credit card), is it possible to figure out the person's height?

enter image description here

Best Answer

It should be relatively clear that without any reference objects, it is not possible to determine how tall the person is or how far away from the camera he or she is standing [1]. However, we can find a relationship between those two values [2]. I hope the proof below will address both of these points.

[1] Imagine that besides the person, all other parts of the image you take are blurred - specifically, there are no reference objects which you know the height of. Say we have an image of a person who is actually $l$ cm tall, appears to be $h$ cm tall, and is standing a distance $d$ cm from the camera lens. Since we have no reference objects, we should get multiple values of $l$ and $d$ that make for a similar image height $h.$ As we increase both $l$ and $d,$ our person's image height $h$ can remain constant.

[2] Though we may not be able to find either $l$ or $d$ given $h$ and specifics on the camera position, there is obviously a relationship between the values. Denote the phone image height $m,$ and the phone's vertical view field angle $x$ (these should be specification constants you can find). Notice that when the phone is tilted up, this angle $x$ is sweeping a larger and larger view field. We can quantify this with the value of the phone tilt, which we call $y.$ We see that $y = \arctan(\frac{i}{j})$ by trigonometry.

Again using trigonometry, we find the vertical view field to have length $d(\tan(y + \frac{x}{2}) - \tan(y - \frac{x}{2})).$ Now using a basic proportion, we see that $\frac{h}{m} = \frac{l}{d(\tan(y + \frac{x}{2}) - \tan(y - \frac{x}{2}))}.$ Rearranging, we have that $\boxed{\frac{d}{l} = \frac{m}{h(\tan(y + \frac{x}{2}) - \tan(y - \frac{x}{2}))}}.$ Notice from earlier that $y = \arctan(\frac{i}{j}).$ All other values on the right side of the equation above can be found via tech specs or measurements. If you know either $l$ or $d,$ you can find the other value with the equation.

Related Question