1

I am currently implementing LSH using FLANN.

matches = flann.knnMatch(des1,k=2)

des1 is a binary descriptor of my query image & flann is the flanbasedmatcher (using the FLANN LSH algo) variable which has all the binary descriptor of an image database.

How do I output the result of the knnMatch?

GStack
  • 33
  • 5
  • Are you sure about the syntax? According to their [documentation](http://docs.opencv.org/trunk/doc/py_tutorials/py_feature2d/py_matcher/py_matcher.html), it need 2 descriptors to check for the matching. PS: You can find how to display the result in the link, too. – Ha Dang Feb 26 '15 at 10:38

1 Answers1

1

You might want to take a look to this link It's an opencv sample showing how to use a FlannBasedMatcher. There is a lot of topics talking about this, you should search better before asking.

Edit

I assume you have a FLANN Index to match with des1, so there is a function that returns if there is a match or not.

MIN_MATCH_COUNT = 10
def flann_match(des1):
    matches = flann.knnMatch(des1, k=2)
    # Check the distance to keep only the good matches.
    matches = [m[0] for m in matches if len(m) == 2 and m[0].distance < m[1].distance * 0.75]
    if len(matches < MIN_MATCH_COUNT)
        return False
    return True

This implementation is quite simple, you'll need to use cv2.findHomography() (documentation) to get better and more accurate results, depends of what is your goal here.

Hope it helps.

Misery
  • 495
  • 4
  • 17
  • You are completely right, but I thought there was too much code to paste here to make any sense. This link is from opencv docs, I don't think it will become unavailable. Just in case, you can find this file in opencv 2.4 : `/samples/python2/plane_tracker.py` – Misery Apr 14 '15 at 10:06
  • the link is broken – user3085931 Jul 22 '16 at 14:18