OpenCV: what does cv2.warpPerspective do? / trying to understand homographies

2.7k views Asked by At

I have been able to transform/warp images with a homography matrix using the cv2.warpPerspective function. However, when I do not use openCV and want to use something more low level - currently, I'm using OpenGL to draw some graphics and I want to apply a known homography matrix to specific vertices, I am unable to apply a homography matrix as such:

For point (x, y), I make it (x, y, 1). Then with my homography matrix H, I multiply H*(x,y,1). H is 3x3 matrix and (x,y,1) is 3x1, so I obtain a new (x',y',z') that is 3x1. But this point doesn't seem to be correct?

I have been able to get the correct transformed new point using the method here: https://math.stackexchange.com/questions/296794/finding-the-transform-matrix-from-4-projected-points-with-javascript but I really want to know why this is not working!

1

There are 1 answers

0
alkasm On

This is an old question but I just saw it in Related on the page to a question I recently answered, and figured I'd chime in here in case others stumble upon this. See here to answer the direct question of why your points were incorrect, and here for a very detailed answer discussing exactly how points are transformed and how you can map them yourself.