OpenCV: use homography for different image sizes
Asked Answered
T

1

5

I calculate the homography matrix of an image using OpenCV's findHomography and then I warp the image using warpPerspective function. Now I want to use the same homography matrix for a scaled version of the image (the scaled version has the same aspect ratio, and the image is scaled around it's center). The problem is similar to "opencv update homography matrix to fit on an image double the size" which does not seem to have a correct answer.

Is it possible to apply a scaling factor to an existing homography matrix?

Regards

Turbulence answered 3/5, 2013 at 13:30 Comment(0)
V
7

If you want to apply the same deformation but on a smaller image, then you do not need to change the homography.

If you want to change the scale factor of the homography, you can obtain the new homography matrix by multiplying the previous one on the right by: [ 1/lambda 0 0; 0 1/lambda 0; 0 0 1 ] (in row-major order), where lambda is the desired scale factor.

Vern answered 3/5, 2013 at 14:32 Comment(2)
this works perfectly when the resulting image is scaled, but what if the input image is scaled also?Predestinate
@fuximusfoe I think my answer works for you https://mcmap.net/q/1052516/-how-to-change-the-homography-with-the-scale-of-the-imageLansing

© 2022 - 2024 — McMap. All rights reserved.