Geometry of Perspective Projection

Measure distance/length and position from a single photo.

By vanishing points:
Vanishing points lie in a particular line called the horizon.

Connecting these vanishing points gives you information whether the camera is tilted or not with respect to the ground floor, and also an idea about where the camera center of projection is, and where the rays are going.

By unwarping/deforming parallel lines:

unwarping/deforming parallel lines and converting their angles to 90 degrees allows known calculations and enables measuring distance.

Basic camera information used for this:
f = focal length
a = lens distance from image(Y)
b = lens distance from plane(y)
formulas:
When two rays intersect in one point (sharp image): 1/f = 1/b+1/a.
When they don’t (blurry image): 1/f != 1/b+1/a.
Ratio between image distance/length and plane distance/length: Y/a = y/b