Ask Your Question
1

Object recognition knnmatch

asked Jan 30 '13

muthu gravatar image

updated Jan 31 '13

Hello... I extracted features from a train image and query image using

FeatureDetector detector = FeatureDetector.create(FeatureDetector.ORB);
detector.detect(pic, keypoints1);
DescriptorExtractor extractor = DescriptorExtractor.create(DescriptorExtractor.ORB);
extractor.compute(pic, keypoints1, featuresofqimg);

I did this for both images...i wanna match these features and i used

       DescriptorMatcher matches =DescriptorMatcher.create(DescriptorMatcher.FLANNBASED);
       matches.knnMatch(featuresofqimg, featuresoftrainimg,  matc, 2);

but the app stops unexpectedly... pls help me over here...

I initialized matc as follows

private List<MatofDMatch>             matc1;

and i don't know how to initialise it..

Also a 2-d variable is required for match...Mat is already 2d ,I wonder why List<matofdmatch> is needed..Its the syntax of the arguments in knnmatch();

pls help me over here.

Preview: (hide)

1 answer

Sort by » oldest newest most voted
2

answered Oct 28 '13

ThevenonP gravatar image

knnMatch outputs the list of k nearest neighbours as a vector<vector<dmatch>>. It means that for each feature in the query image, it will output k (or less) DMatch, hence the need for a 2D structure.

If you only need 1 neighbour for each query image feature, you can use the .match() method, with the output as a vector<dmatch>.

Preview: (hide)

Question Tools

Stats

Asked: Jan 30 '13

Seen: 1,839 times

Last updated: Oct 28 '13