# Calculate distance to person from camera if camera is on the floor

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?

• Do you know the camera’s field of view, in degrees for instance? – Lubin Jan 9 '16 at 21:44
• @Lubin Yes, it's a camera phone, so either through the spec sheet or just manually testing it. – Misha M Jan 10 '16 at 0:27
• There are all sorts of photographico-mathematical objections to doing what you want, and I think your idea of using a comparison object would be much preferable. There’s the foreshortening of the body because the camera’s not looking at it straight-on; there’s the problem that the imaging of the camera will not be linear (objects at the edge of the field of view will be stretched), and probably more that I’m not thinking of right now. – Lubin Jan 10 '16 at 3:26
• Going to use camera calibration from OpenCV to deal with the camera being at an angle. Not too worried about the edges of the image yet. At the moment, trying to figure out if this is possible without using a comparison object or not. – Misha M Jan 11 '16 at 23:21

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.

• @k-jiang thank you for the response. The problem I'm having is how to solve the problem if you don't know l or d – Misha M Jan 19 '16 at 1:46
• No problem. That's the thing. I think I described it in part [1] above, but consider this: a really small person up close to the camera would appear similar in size to a large person far away from the camera. You would need to know one in order to find the other - otherwise, you can't calculate either. – K. Jiang Jan 19 '16 at 2:04
• Exactly, that's what I got hung up on. I'm trying to understand how MTailor app works, since they don't require you to have any reference object. I have a solution if you hold a reference object, but was wondering how to do it without one. Thank you – Misha M Jan 19 '16 at 7:26

Your question at first seems impossible to answer with the information given, but after a closer look, I suspect you have left a clue or two in your statement that allows your answer to be estimated to a reasonable degree. I will have to make an assumption or two to get that estimate, so here we go: 1. Let the angle between the wall and the camera be phi such that tan (phi) = i/j. That will also be the angle of the midpoint of the field of view of the camera relative to the floor, from basic trig. 2. Now I assume you want to photograph the whole person as centered in the photograph, producing equal borders above and below him/her, neglecting any edge effects caused by the camera not pointing horizontally. Thus we have the midpoint of the field of view pointing at the midpoint of the person. 3. Next you measure the floor distance from the persons feet to the camera edge on the floor, and call it G. The last 4 lines of your description of the problem suggests you are looking for a triangle, and once you have it, and it doesn't involve a comparison object, you are at liberty to measure G and complete your triangle.
Y  = 2(i+G)tan(phi)+ 2j  .