### Measuring the speed of an object with variable distance from camera

Hi guys,

In the past few months, I've gotten to understand the how opencv works and how best we to detect and track a moving object with background subtraction. From the BGS I managed to get the distance of the object I am tracking as I'm using a D435 stereoscopic camera. So with the x, y in px and z in meters, how should I go about in calculating the distance of the object I'm ~~tracking. ~~tracking.

I briefly understand ~~it has something to do with ~~that from vector calculation its sqrt( (x2 - x1) ** 2 + (y2 - y1) **2 ), but how does the ~~angle of the camera, but I'm not too well-versed in that. ~~z depth affect this?

Any help would be appreciated. Thank ~~you. ~~you.