Removing Z rotation from homography matrix before warpPerspective

asked 2017-04-21 04:02:45 -0500

I'm trying to stitch together Images. I have homography matrix from findHomography() which I then pass to warpPerspective(). My issue is that all of the images are flat 2D ones, meaning they will never need any Z rotation. The findHomography(), however, thinks otherwise. How do I disable Z rotation in homography matrix?

edit retag flag offensive close merge delete


Are you trying something like this?

LBerger gravatar imageLBerger ( 2017-04-21 04:36:10 -0500 )edit

@LBerger No, I'm actually doing the opposite of this. If my explanation is not clear, imagine taking a bunch of screenshots of this page. Now we want to stitch all of them together into one big image. All of our screenshots of this page are perfectly flat 2D and don't need any Z rotation. I have similar type image and I'm trying to achieve something like this. The issue is that findHomography() adds tiny bit of Z rotation which I want to get rid of.

Ignas2526 gravatar imageIgnas2526 ( 2017-04-21 05:45:23 -0500 )edit

I think it is not a homography you need but rather an affine transformation (getAffineTransform()). You can take a look at this also.

Not sure to understand what you mean by no z-rotation. Using the screenshot example, there are no rotation at all, only translation. If the image is let's say 90° in-plane rotated, there is a rotation around the z-axis of the camera. Anyway, if your model is simple, you should estimate yourself the transformation matrix and pass it to warpPerspective() or warpAffine().

Eduardo gravatar imageEduardo ( 2017-04-21 11:17:00 -0500 )edit