# Calculation for getting dimension of object in image [duplicate]

I am trying to calculate the dimensions of an object in an image. This is a sample image I took to get height of the brown box. I have this white box which measures 16cm and I would like to know the height of the brown box (in meter). This using only the focal length and the size of the camera sensor of my phone. Focal Length: 3.99mm Focal Length In 35mm Size: 29 mm Sensor size: 4.8mm * 3.5mm Height of the image: 4032px Size of the brown box in pixels: 1459px Distance between the sensor and the box: 1.8m I did this: So I found boxheight = 0.78m In reality, this brown box measures 0.75m, so I want to know if itâ€™s possible to obtain a more accurate result by using the fact that I know the exact size of the white box next to it. Does anyone know ? Thank you

• You're close, so I am thinking one of your variables is off by a tad. Film frame size is commonly referred to as 6x6, 6x7, etc., but these dimensions often vary slightly for each camera model. Could it be that your sensor is actually not precisely what you wrote in your calculations? – timvrhn Jun 25 '19 at 20:43
• What's the pixel height of the white box? Wouldn't 16cm * pixel_height_brown / pixel_height_white be a simpler approach? At least with the assumption that the vertical sides of the boxes are contained within the focus plane... If so, the white box pixel height should be ~311 pixels... – twalberg Jun 25 '19 at 20:47
• I'm voting to close this question as off-topic because it is about using a camera as a measuring device rather than to produce photographs for their artistic, documentary, or historical value. That, and the fact we already have 3,527 other versions of the same question. – Michael C Jun 26 '19 at 18:14

You're making the calculations too complicated. When you have a known reference measurement in an image to compare the unknown against, just use the known reference as the unit of measurement.

In my image editor, I measure the height of the white box as ~176 pixels, and the height of the brown box as ~884 pixels. The brown box is thus 884/176 = 5.02 times taller than the white box.

And because the white box is given as 16 cm, the brown box is therefore 16 * 5 = 80 cm tall.

Note that this is exactly what crime scene photographers do when they lay down a forensic ruler / scale next to something they want to photograph at the scene.

Forensic photo scale

You also sometimes see police lay down a coin or a dollar bill next to the item being photographed if they don't have a forensic scale with them. (At least, you see it sometimes on law/police procedural TV shows and movies. Whether or not that is common or rare in real-world police work, I don't know). The point is to put a known reference measurement in the photograph, so future analysis of the photographed evidence will can always be done.

• "a known reference measurement in an image to compare the unknown against" on (almost) the same plane – jhamon Jun 26 '19 at 7:39
• There is long standing tradition of putting the hammer in the frame in paleontoloogy photos. – xenoid Jun 26 '19 at 9:31
• @jhamon Absolutely. Good point. – scottbb Jun 26 '19 at 11:06