# Calculating height of an object

I do not know if this is the place for this question but I am sure I will be told sooner rather than later. Basically I want to know the following.

Is there a way to calculate the height of an object from a certain position.

Example:

A Camera which has taken a picture. The camera was 3 meters off the ground, there is an object 10 meters into the distance. Is it possible to estimate the height of the object.

please see image before to help explain this issue. • At What angle was the camera to the treetop? That is important. So actually there is not enough information to answer the question! – user237430 May 3 '15 at 8:23

You can calculate the height of an object using the distance and angle.

distance * cos(angle), where distance is the horizontal distance to the object, and angle is the angle above horizontal of the top of the object (from the viewer). The result will be the height above the viewer.

With a camera, you need more information because you don't necessarily have the angle.

You can estimate the angle by taking a similar photo at the same zoom with known angles, and compare the distance on the two photos between horizontal (or vertical) and the angles. It will be more accurate if you have horizontal (or vertical) in the same place on the two photos.

You might also be able to determine the angle in the photo by the alignment of two objects of different distances from the camera.

Well, here is a sufficient condition: Depending on how well you aim the camera, the center of the photo will correspond to a horizontal line $3m$ high extending out indefinitely. If you are on a level surface, the object intersects the 'center photo line' and the bottom of the object appears in the photo, then you know that the distance from the bottom of the object to the center of the photo is $3m$. You can then estimate the height knowing the scale.

You will need to know the following information about the camera to determine the height of the object:

1.) Focal length of camera lens. This can be looked up in the camera's spec sheet. You might run into problems with an auto zoom camera, so try to disable auto zoom.

2.) Pixel size of camera CCD. This can also be acquired from a spec sheet.

The other parameter is the distance of the object from the lens focal plane. This was given in your example as 10 meters.

The diagram below expresses the relationship between the object and its image on the camera CCD visually: From Wikipedia, the thin lens formula describes these relationships:

$$\frac1f=\frac{1}{S_1}+\frac1{S_2}$$

And:

$$\frac{S_1}{S_2}=\frac{H_{object}}{H_{image}}$$

Therefore:

$$H_{object}=\frac{f\times H_{image}}{S_1-f}$$

$H_{image}$ is equal to the number of pixels in the camera image times the pixel size. This will allow the equation to use all the same units. $H_{image}$, $f$, and $S_1$ are now all known, and it is possible to solve for $H_{object}$, the height of the object.