0

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!

Community
  • 1
  • 1
korp
  • 13
  • 5
  • See [THIS POST](http://www.pyimagesearch.com/2014/05/05/building-pokedex-python-opencv-perspective-warping-step-5-6/) for more and its related links – Jeru Luke Jan 03 '17 at 12:23
  • @JeruLuke I have seen this, and i can use cv2.warpperspective correctly no problem. My issue is, why can't I just multiply the matrix to points directly? – korp Jan 10 '17 at 08:34
  • to do that you could use the 'cv2.findHomography()' function. Get the points from the **source** image that you want to map on to the point in the **destination** image. – Jeru Luke Jan 10 '17 at 09:02
  • @JeruLuke thank you for responding :) But I have already the matrix for homography. My issue is with the application of the homography matrix to the points. – korp Jan 12 '17 at 13:48
  • The application of using a homography matrix is to align image 'A' with respect to image 'B'. For this purpose they take 4 points of each of these images 'A' and 'B'. The base line is: Homography matrix is used for alignment. – Jeru Luke Jan 12 '17 at 14:38

1 Answers1

1

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.

alkasm
  • 22,094
  • 5
  • 78
  • 94