0

I have an image that is an image of one of a set of objects, and I'd like to use SIFT in Open CV to figure out which object it. I have this code:

Mat pic = imread(...);
vector<KeyPoint> picKP;
Mac picDesc;

Mat obj1 = imread(...);
Mat obj2 = imread(...);
Mat obj3 = imread(...);
vector<KeyPoint> obj1KP;
vector<KeyPoint> obj2KP;
vector<KeyPoint> obj3KP;
Mat obj1Desc;
Mat obj2Desc;
Mat obj3Desc;

SIFT sifter = SIFT();

sifter.detect(pic, picKP);
sifter.detect(obj1, obj1KP);
sifter.detect(obj2, obj2KP);
sifter.detect(obj3, obj3KP);

sifter.compute(pic, picKP, picDesc);
sifter.compute(obj1, obj1KP, obj1Desc);
sifter.compute(obj2, obj2KP, obj1Desc);
sifter.compute(obj3, obj3KP, obj1Desc);

FlannBasedMatcher matcher;
vector<DMatch> matches1;
vector<DMatch> matches2;
vector<DMatch> matches3;

matcher.match(picDesc, obj1Desc, matches1);
matcher.match(picDesc, obj2Desc, matches2);
matcher.match(picDesc, obj3Desc, matches3);

It generates a vector<DMatch> to compare my picture with each potential picture. But I don't know what to do with the 3 vector<DMatch>es to figure out which one is the best match.

Note: I'm doing this mostly to try and learn about SIFT, so even though I know better ways are available for my particular dataset, I still want to try to do it with SIFT.

Drew
  • 12,578
  • 11
  • 58
  • 98

1 Answers1

0

See the API for DMatch data type here: http://docs.opencv.org/modules/features2d/doc/common_interfaces_of_descriptor_matchers.html#dmatch

D.J.Duff
  • 1,565
  • 9
  • 14