# how can I estimate the depth of an object with a bound box from just a few images where i moved it?(knowing how much i moved)

how can I estimate the depth of an object with a bound box from just a few images where i moved it?(knowing how much i moved)

For testing purposes I have a cube and a camera perpendicular to it and I need to estimate its z-axis and I only have a few images of it moving backwards or forwards.

• Do you have the intrinsic parameters of your camera? Commented Oct 25, 2023 at 4:16

If the camera model and the scene settings are as simple as what you've stated in the post, I think simple geometry will do. Note that $$f$$ is the focal length and $$p_i$$ is the projected pixel length for one of the edges of the bounding box. $$x$$ is the unknown 3D length of the bounding box, $$t$$ is the distance you moved (known) and $$d$$ or $$d-t$$ is the depth you want.

For more generally-purposed depth estimation, I think these are some methods you can try. Since it is easy for you to get the correspondences between images (especially when you have bounding boxes), you can use:

• Triangulation: two known scene view points (two images) and the pixel coordinates projected by that 3D point. In an ideal situation, two rays from the pixels should intersect on that very 3D point of which the depth you want, but due to noise and discrete quantization (2D images), these two rays won't intersect. Therefore the depth is usually recovered from least-square methods.

• PnP algorithms. You have at least four pairs of points (your bounding box). Using PnP algorithms, you can even recover the 3D position of each points in the camera coordinate frame, so depth won't be a problem.

Even if you don't have bounding boxes, using feature point based pixel correspondence search should get you point pairs you need. For the methods above, you will need:

• Camera intrinsic matrix (if it is CG generated, this is usually simple and only related to camera focal length).
• Viewpoint transforms. As you've said, you know the transforms between different cameras, so this won't be a problem.
• Pixel correspondences. For points of which depth is to be calculated, you should know the pixel coordinates for those points in at least two images. This won't be a problem for you.