This is a Python demo program that demonstrates use of cv2.Rodrigues() and cv2.warpPerspective() to rotate an image.
This has been tested using Python v2.7 and OpenCV v3.2 on OSX Sierra v10.12.3.
Just launch the program from the command line. That will open two GUI windows. One with the unadorned original image. The second with three sliders to rotate the image around the x, y and z axis. To close, press any key with the GUI in focus.
This module was derived from a question on StackOverflow.com: http://stackoverflow.com/questions/19987039/inverse-perspective-transformation The code has been migrated from cv to cv2 and significantly modified for style.
The demo image is provided by Pixabay.com https://pixabay.com/en/garden-park-castle-art-2040714/