Ask Your Question
0

Only one match per keypoint

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

Mehdi gravatar image

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

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)
    self.bf = 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
2

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

Eduardo gravatar image

Hi,

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

edit flag offensive delete link more

Comments

Thanks ! somehow I oversaw this in the docs

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

Question Tools

1 follower

Stats

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

Seen: 881 times

Last updated: Jan 29 '15