How to fit a rectangle into a space (get relative

2019-08-30 01:25发布

问题:

Say we have a web cam image of a road. We have picked 4 connected 2d lines of a rectangle, and we know there are 90deg angles between them. We have set their real life dimentions. How one can get 3d camera position relative to that rectangle from such data?

回答1:

Having 4 pairs of corresponding coordinates - real word ones and coordinates at camera matrix (in photo image coordinate system), one can calcalate matrix of perspective transformation, for example, with OpenCV function getPerspectiveTransform.

Then apply decomposeProjectionMatrix

If you are using another means/libraries for image acquisition/treatment, they might contain something similar