Ask Your Question

Revision history [back]

Image rectifying using homography matrix

Hello!

I'd like to transform an image using homography matrix.

That is, when I have an image taken at a certain position and attitude,

I want to get an image taken at a different position and attitude.

It is like a rectification, but I want to use homography matrix (which is obtained from information of translation and rotation) as the transform.

I have no idea of right OpenCV function to do that.

I tried warpPerspective(), but it produces awkward result. (1kb image)

Could you advise me to solve the problem?

My code goes like

Mat src = imread("tests/image3.jp2", IMREAD_COLOR);
Mat dst, M;
float H33[3][3];

//
//...calculate homography matrix H33
//

M = Mat(3, 3, CV_32F, H33);

warpPerspective(src, dst, M, Size(sideLength, sideLength));

imwrite("tests/image3_warp.jp2", dst);