Search code examples
python-3.xopencvobject-detection

3D object localization from 2D image


I have a 2D image with vehicles localized by 2D bounding boxes in it. Also I have the 3x3 homography matrix and the reprojection error from camera calibration. Are these information enough to find the 3D position of the vehicles?

This is my very first question in here, so please let me know if I need to provide more information.


Solution

  • It is impossible to get 3D coordinates from 2D image. You can map each pixel to the ray that comes from camera nodal point and goes through that pixel but to get 3D coordinates you need also the depth value in this pixel. Consider following example: The vehicle of the size S is located at the distance d to the camera. Similar vehicle that is two times bigger (size 2S) is located at the distance 2d to the camera. They are projected exactly the same on the image. So you can get 3D positions up to unknown scale factor only. However, you can estimate the location of each vehicle that if you know the real world size of them.