Ask Your Question

Only one match per keypoint

asked 2015-01-28 20:59:59 -0500

Mehdi gravatar image

updated 2015-01-29 01:16:56 -0500

berak gravatar image

I am trying to use Lowe's criteria to remove bad matches but I realised that I get only one match per keypoint. Why is that? Those are my matcher, detector and descriptor

    self.brisk = cv2.DescriptorExtractor_create("BRISK")
    self.detector = cv2.GFTTDetector(maxCorners=100, minDistance=1) = cv2.BFMatcher(cv2.NORM_L2)

And the function I use to remove bad matches by comparing the distance of the first best and second best matches, but I only have the first best match (for each m in matches there is only one DMatch object and not an array).

def filterMatches( kp1, kp2, matches, ratio = 0.75 ):
    mkp1, mkp2 = [], []
    for m in matches:
        if len( m ) == 2 and m[0].distance < m[1].distance * ratio:
            m = m[0]
            mkp1.append( kp1[m.queryIdx] )
            mkp2.append( kp2[m.trainIdx] )

    pairs = zip( mkp1, mkp2 )

    return pairs
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2015-01-29 03:28:02 -0500

Eduardo gravatar image


Use knnMatch instead of match to get the k best matches for a query keypoints.

edit flag offensive delete link more


Thanks ! somehow I oversaw this in the docs

Mehdi gravatar imageMehdi ( 2015-01-30 00:58:47 -0500 )edit

Question Tools

1 follower


Asked: 2015-01-28 20:59:59 -0500

Seen: 560 times

Last updated: Jan 29 '15