Click here to Skip to main content
16,021,211 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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


C++
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);
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900