How can I find out the real height of an object from a photo?

I did a lot of searching but still haven't found a way to calculate the height of objects based on pictures taken with my camera.

Here are my variables:

The distance between the object and my camera: 116 cm.
The object's real height: 17 cm.
The height of the object in my photo: 574 px.


How exactly can I find out the height of different objects at that exact distance?

• We definitely would need more information. I don't know what exactly, but how even something like resolution of the picture could change to produce different results. (574 px in a 640x480 image is very different from 574 px in a larger image) – jwc845 Sep 28 '18 at 15:38
• Is the zoom also constant? – Mohammad Zuhair Khan Sep 28 '18 at 15:39
• The size of the image is always constant: 5312 x 2988 px – Sorin Haidau Sep 28 '18 at 15:46
• There is no zoom. – Sorin Haidau Sep 28 '18 at 15:47
• Isn't it just a proportion? The distance of the object shouldn't even count, if it remains constant. $x/574 = y/17$, where $x$ is the pixel height of the object and $y$ is the real height of the object in cm – Exodd Sep 28 '18 at 15:55

Pretending that the lens is a thin lens, you have a pair of similar triangles through the center point of the lens. One is a right triangle with legs $$17$$ and $$116$$ cm. The other has a leg corresponding to $$17$$ cm is your $$574$$ px. To finish the calculation you need the distance from the lens to the sensor in pixels. That is probably hard to find.
Another approach is to use the size of the picture in pixels and the angle of view of your lens. If you know the angle of view you can compute the height of the picture in cm at the distance of $$116$$ cm and compare that to the total number of pixels in the frame.
Another approach is to take a picture of a ruler at a distance of $$116$$ cm and see how many pixels it represents.