Wahab Raja
Wahab Raja

Reputation: 51

Estimate geometric transform in Opencv c++

Actually I want to use "estimated Geometric transform" matlab's function in opencv c++, is their any kind of such function which works exactly same in opencv in c++?

Matlab function

Note: I am using this function for creating bounding box around pair of eye on the basis of features, which are not static in every frame...

Upvotes: 1

Views: 3534

Answers (1)

valleymanbs
valleymanbs

Reputation: 487

I think that what you are trying to get is an affine transformation matrix from image1 to image2. Given the coordinates of a matched set of points in image1 and image2, you can get the affine transformation matrix using estimateRigidTransform: as the docs point out, this function can be used giving as input two sets of pre-calculated matched points, or even directly giving as input two images: the function will internally find features that match in both images and will use those matched points to get the optimal affine transform matrix.

As the user Micka correctly suggested in the comments to your question, since you got features that can be translated, rotated but also scaled, you need to set the flag fullAffine to false.

Since you are talking about frames I suppose you are trying to match points in a visual flow, so this is surely the function you need. The same can be obtained images which could also have shearing with getAffineTransform: given a set of points in two images, this opencv function will return a 2x3 affine transformation matrix. To understand better what is an affine transform (and thus understand better the similarity transform, in you case) you can refer to the following docs. They are quite the same, just two versions for the two current OpenCV branches.

I prefer the layout of the 2.4 documentation, but the explained concepts are absolutely the same.

OpenCV 2.4:

http://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html

OpenCV 3.2:

http://docs.opencv.org/3.2.0/da/d54/group__imgproc__transform.html#ga8f6d378f9f8eebb5cb55cd3ae295a999

Upvotes: 3

Related Questions