Ask Your Question

Sandman's profile - activity

2015-07-08 23:00:53 -0600 asked a question Flann KNN Matcher in OpenCV returns only one point instead of a pair

When I run the Flann KNN matcher, then there are certain times when the KNN matcher only returns one point because of which code after the matcher that relies on there being two points fails:

flann = cv2.FlannBasedMatcher(index_params, search_params)

matches = flann.knnMatch(descriptors1, descriptors2, k=2)

# Retrieve good matches
good_matches = []

# ratio test as per Lowe's paper
for i, (m, n) in enumerate(matches):
    if m.distance < 0.7*n.distance:
        good_matches.append((m, n))

Throws this error:

Traceback (most recent call last):
  File "main.py", line 161, in <module>
    main(vid, video_file)
 ...
  File "main.py", line 73, in consume_for_homography_error
    matches = flann_matcher(descriptors1, descriptors2)
  File "main.py", line 48, in flann_matcher
    for i, (m, n) in enumerate(matches):
ValueError: need more than 1 value to unpack

What seems to be the problem here?