Ask Your Question
0

[Python] FlannBasedMatcher image retrieval

asked 2015-06-13 20:33:47 -0600

I have a database of images that I'm searching through.

For each image I:

calculate descriptors with SIFT
use flann.add([descriptor]) (where flann is a FlannBasedMatcher)

I then use flann.knnMatch() to find matches for a target image

I'm able to get matches, but I'm struggling to piece together which image 'matched' my target image. I have a collection of dmatch object-pairs, but I don't know how to associate it with one particular image or its descriptors. In other code examples people create a sort of look up table based on the number of descriptors an image had, but even that doesn't quite make sense to me.

Thanks so much for any help!

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2015-06-17 01:31:10 -0600

ToString gravatar image

Hi there,

I did a similar project to yourself. See this link for a good example of how to use FLANN matcher.

I suspect your main problem is your architecture, and that you should possibly store the keypoints/descriptors in a file or database for retrieval. Then you can try match 1 by 1 and sort by some sort of metric (this could be domain specific). You could sort by:

  • Total number of matched points.
  • You could assess the generated Homography matrix if you can implement some rules about how the image has projected or transformed.

In my project, I saved the image, keypoints, descriptors and the name of the image, in a database (SQLite). This seemed to work very well. It also helps identify which image you are using.

This should help you get accurate results.

edit flag offensive delete link more
0

answered 2015-06-14 01:15:11 -0600

updated 2015-06-14 01:15:40 -0600

I figured out that I can do this by using the imgIdx property on the DMatcher object. The imgIdx property is the order unto which the descriptor was added to the flannbasedmatcher with flannbasedmatcher.add(descriptor).

Having more problems though..

when I call train() on the flannbasedmatcher it seems to run extremely quickly. Like it's not doing anything. The subsequent matching is taking a really long time as well.

What I'm trying to do in a nutshell is:

1) cram a bunch of image descriptors in a flannbasedmatcher
2) match one image against this large number of descriptors
3) see which image has the most matches against the target image
4) display this image to see if it found the right thing

Also, I'm a huge noob to this, so ignorance could certainly be at play here

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-06-13 20:33:47 -0600

Seen: 1,279 times

Last updated: Jun 13 '15