title: OpenCV length of matches in BFMatcher
body: <p>
  I am trying to use SIFT on two images and match the keypoints using BFMatcher in OpenCV. </p>
  
  <p>However, the number of matches is not equal to the number of query descriptors. Can someone explain why they are not equal?</p>
  
  <p>According to <a href="https://docs.opencv.org/master/db/d39/classcv_1_1DescriptorMatcher.html#a0f046f47b68ec7074391e1e85c750cba" rel="nofollow noreferrer">docs</a>
  <code>match()</code> function <strong>"Finds the best match for each descriptor from a query set."</strong></p>
  
  
  
  <pre><code>import cv2
  import numpy as np
  
  im1 = cv2.imread("trex1.png", cv2.IMREAD_GRAYSCALE)
  im2 = cv2.imread("trex2.png", cv2.IMREAD_GRAYSCALE)
  
  sift = cv2.xfeatures2d.SIFT_create()
  kp1, des1 = sift.detectAndCompute(im1, None)
  kp2, des2 = sift.detectAndCompute(im2, None)
  
  im_kp1 = np.zeros(im1.shape, dtype=np.uint8)
  im_kp2 = np.zeros(im1.shape, dtype=np.uint8)
  im_kp1 = cv2.drawKeypoints(im1,kp1,None)
  im_kp2 = cv2.drawKeypoints(im2,kp2,None)
  
  bf = cv2.BFMatcher(cv2.NORM_L2, crossCheck=True)
  matches = bf.match(des1,des2)
  
  print len(des1)
  # Result : 78
  print len(des2)
  # Result : 71
  print len(matches)
  # Result : 55
  </code></pre>