# Relationship between depth and the vertical displacement of the object between two frames

I am trying to find the relation between the vertical displacement of an object to the depth of the object.

Say, there is an object in an image and as the center of gravity of this object moves vertically upwards, we know that it is moving away from the camera.

We know at the same time, that the dimension of the image would reduce because the object is moving away from the camera.

So, two things are happenning - 1 . the objects center of gravity is moving up vertically and 2. the object dimension is decreasing because the object is moving away from the camera.

Is it possible to find a relationship between "the vertical displacement of the object from one frame to another frame" and "the distance of the object from the camera from one frame to another frame" ?

## 1 Answer

Yes. This all comes down to some simple trigonometry. An object that is at horizontal distance $x$ and vertical distance $y$ from the camera's viewing direction will be at angle $\tan^{-1} (y/x)$ from the viewing direction, and the distance to the object will be the length of the hypotenuse, i.e., $\sqrt{x^2+y^2}$ (draw a picture).

So, if the object starts at height $y_1$ and then moves upward to height $y_2$, the distance to the object will increase from $\sqrt{x^2+y_1^2}$ to $\sqrt{x^2+y_2^2}$. Now you can compute the absolute or relative change in the distance to the object, if you know $x,y_1,y_2$. For instance, if you know the distance to the object originally and the original angle $\theta_1$ from the camera's viewing direction, you can compute $x,y_1$; if you know how much it moved upward, you can compute $y_2$; and that will let you compute the new distance.