OpenCV perspective transform with camera roll and pitch correction
If the camera motion is approximately a rotation about its optical center / lens entrance pupil (for example, pan-tilt-roll on a tripod with the subject distance much larger than the translation of the optical center), then images taken from rotated viewpoints are related by a homography.
If you know the 3D rotation (pan/tilt/roll), then you can explicitly compute the homography and apply it to the image. If not, but you have two images upon which you can identify 4 corresponding points or more, then you can estimate the homography directly from those correspondences.
I am performing some perspective transforms on camera images, however in certain cases the roll and pitch of the camera are not zero. In other words, the camera is not level and I would like to be able to correct for this.
I have some questions:
1) Can the transformation matrix (from M = cv2.getPerspectiveTransform(...) ) be corrected for the pitch and roll angles?
2) Should I just transform the source points and get a new transformation matrix? Roll seems like a simple enough correction since it's analogous to rotating the image, but how can I get the proper transformation for both roll and pitch?