1 | initial version |

You want to look at the solvePnP function. It is designed to give you the translation and rotation between world points and the camera. You have four points, the end of each axis and the origin. I assume you know how long the vectors are in real space? Or at least that they are all the same length?

Set the four points as (0,0,0), (1,0,0), (0,1,0), (0,0,1) and then the image points are, of course, what you see in the image. I would use the SOLVEPNP_P3P method, since it requires exactly four, and you have exactly four points.

Once you have your rvec and tvec, you have everything you need to transform the image to view it from above.

Copyright OpenCV foundation, 2012-2018. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.