user3196672
user3196672

Reputation: 31

estimateRigidTransform in OpenCV python

I'm using OpenCV in python. The documentation is killing me. How do I use estimateRigidTransform correctly?

I'm trying to extract the similarity transform between two images, so I assume I cannot use findHomography b/c I do not want to introduce shear, etc. EstimateRigidTransform seems like the perfect candidate but I'm just receiving an output of "none". What are its inputs? Has anyone used it correctly for even for a simple case?

My code is something to the effect:

img1=cv2.imread('src.jpg')
img2=cv2.imread('dst.jpg')
H = cv2.estimateRigidTransform(img1, img2, False)

I've tried manipulating the inputs to different data types to no avail. I could also input keypoints? or matched keypoints?

Any simple example for two images would be useful!! Thank you

Upvotes: 3

Views: 6230

Answers (2)

raoqiang
raoqiang

Reputation: 41

Yes,you can not transform directly on the image, you should first give the corresponding key point of the two images.

Upvotes: 0

Michael Burdinov
Michael Burdinov

Reputation: 4448

estimateRigidTransform has two modes of work: match between images and match between point sets. To match between images it needs to find points of interest in both images and find which point should be matched to which. I admire the attempt to create a general case algorithm to do so but this is nearly impossible task. So I would recommend you to use second mode of estimateRigidTransform, i.e. match between point sets. First, find the points of interest in images. Second, find the matches between points of different sets. And third, use estimateRigidTransform to find the transform itself. The points should be provided in two arrays of the same size (matching points should be in matching places).

You could use this documentation of estimateRigidTransform. It is simple and very descriptive.

Upvotes: 4

Related Questions