How to convert measure in pixel to 3D space units ?

Found this post, not sure if it will help or not:

But correct me if I’m wrong, you say you can measure how far the object is out of view? If so, just reference that offset, and move the camera until that offset is 0.