开发者

Help With OpenCV warpPerspective and perspectiveTransform

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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜