Ask Your Question
0

Python correctMatches

asked 2012-07-13 15:19:42 -0600

Tommy gravatar image

Hi guys!

Is there anywhere I can look for specifics on the input data requirements for the OpenCV functions for python? I really don't get it. All functions seem to require numpy arrays with different shapes.

For instance. The findFundamentalMat accepts n-by-2 numpy ndarrays of floats, but I fail to figure out what correctMatches wants as input.

Do you guys know? Where can I look this up?

Thanks!

edit retag flag offensive close merge delete

Comments

Also, I am aware that the API reference says that the input points are supposed to be: "1xN array containing the first set of points". But that is not helping. In C or C++ an array of cvPoint2f or vector<Point2f> is accepted, but in Python the point structs are replaced by tuples. However, if I give it an array of tuples I get a TypeError: <unknown> is not a numpy array

Ok, so the input needs to be a numpy array. By if I convert the array of tuples to a numpy array by numpy.array end up with a 2d matrix and obtain the error: "Input parameters must be matrices in function cvCorrectMatches"

And if I instead use numpy.matrix I obtain the same "Input parameters must be matrices in function cvCorrectMatches" error.

Anyone knows?

Do you knowhere the python wrappers are in the source?

Tommy gravatar imageTommy ( 2012-07-15 02:51:57 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2012-07-16 08:38:59 -0600

Tommy gravatar image

Ok, so I figured it out! ;-)

It wants an array with size (1,n,2). The lines

pt1 = np.reshape(pt1,(1,n,2))
pt2 = np.reshape(pt2,(1,n,2))

did the trick.

This is, however, not abundantly clear from the documentation..

I know the python functions are created automatically at build time, so perhaps the problem is not with python, but that the underlying C functions are ambivalent. A clear and concise style, where related functions take the same arguments, is something to strive for.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-07-13 15:19:42 -0600

Seen: 3,710 times

Last updated: Jul 16 '12