Well, that’s why you were right that you needed to use sine and the like. First, you will need to find the viewing angle of the iPhone camera. Do this, place the camera at a known distance from the wall and measure how far it is from the edge of the field of view to the other side and divide it into two parts. To find θ in the figure below, use tanθ = opposite / adjacent, so the inverse tan (opposite / adjacent) = θ.

Once you know this, you just ask the user to take a picture and give an estimate of how big something is actually on the screen. Then just use tanθ = opposite / adjacent, and since you now know θ and the opposite distance, adjacent = opposite / tan θ.

Hope this helps!
source share