0
votes

I have two images, I want to warp one image to align with the second image. Here's what I do.

  • Extract SURF features and Descriptors and find match points
  • Find Homography matrix using matched keypoints
  • Warp Image2 using warpPerspective function

I also have a object bounding box in original image, I want to redraw the bounding box after projection. To redraw the bounding box, here's what I do.

  • create a vector of four corners of rectangle
  • find warped points using perspectiveTransform() function
  • create a rectangle from points and draw the rectangle.

My problem is that, after projection, my new bounding box does not contain the object. Projection of rectangle corners doesn't agree with image projection done using warpPerspective().

Any help?

1

1 Answers

0
votes

Did you normalize the vector coordinates for the rectangle?

If I recall correctly, the perspective transform (during the solving process, for numerical stability reasons) normalizes the coordinates such that the centroid of input points is (0, 0) and mean squared distance is 1.

You should perform the same transform on the rectangle coordinates.