Only one match per keypoint
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