Ask Your Question
0

knnMatch in version 2.4.10

asked 2015-01-28 02:58:39 -0600

Fiong gravatar image

Anyone know how to call knnMatch in version 2.4.10?

I used it in this way, but it doesn't work and met errors. Anyone know how to use it?

std::vector< DMatch > matches;  
BFMatcher matcher(NORM_L2, true); 
Mat mask;
matcher.knnMatch(descriptors_1, descriptors_2, matches, 2, mask, false);  // Find two nearest matches
edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
2

answered 2015-02-09 04:12:12 -0600

Fiong gravatar image

Finally, I solved the problem by changing the declaration of matches :

to be:

  vector<vector<DMatch>> matches;
edit flag offensive delete link more

Comments

Well, for knnmatch you effectively need a vector of vector of knn match, since first you have the best Dmatch for a specific keypoint pair, then you have a vector for all Dmatchs of the image, then a second vector allowing you to store the second best matches with the same structure

This said, beside the change you show in this answer, is the code present in the question works correctly now?

Doombot gravatar imageDoombot ( 2015-02-12 13:55:27 -0600 )edit
0

answered 2015-01-28 03:13:19 -0600

updated 2015-01-29 02:08:55 -0600

Taking a look at the current knnMatch documentation I guess the matcher interface was changed.

It seems that since 2.4.10 you need to use the pointer interface. Something like this should work

Ptr<DescriptorMatcher> matcher; 
matcher->create("BruteForce");
Mat mask;
matcher -> knnMatch(descriptors_1, descriptors_2, matches, 2, mask, false);  // Find two nearest matches

Can you check the result?

edit flag offensive delete link more

Comments

The first line cannot work. Maybe sth w. create? Haven't had a look so far...

Guanta gravatar imageGuanta ( 2015-01-28 14:24:40 -0600 )edit

The edit should work according to documentation :)

StevenPuttemans gravatar imageStevenPuttemans ( 2015-01-29 02:09:08 -0600 )edit

Hi, I have tried you code, but it still doesn't work. Have you tested it? Thanks!

Fiong gravatar imageFiong ( 2015-02-05 04:04:14 -0600 )edit

Nope, It was a suggestion. Can you give us the error that was generated by this code?

StevenPuttemans gravatar imageStevenPuttemans ( 2015-02-05 04:25:54 -0600 )edit

The error is: no instance of overloaded function "cv::DescriptorMatcher::knnMatch" matches the argument list

Fiong gravatar imageFiong ( 2015-02-05 22:25:43 -0600 )edit

Line of code please, where is this error generated.

StevenPuttemans gravatar imageStevenPuttemans ( 2015-02-09 02:59:35 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-01-28 02:58:39 -0600

Seen: 616 times

Last updated: Feb 09 '15