title: BFMatcher match in OpenCV throwing error
body: <p>I am using SURF descriptors for image matching. I am planning to match a given image to a database of images.</p>
  
  <pre><code>import cv2
  import numpy as np
  surf = cv2.xfeatures2d.SURF_create(400)
  
  img1 = cv2.imread('box.png',0)
  img2 = cv2.imread('box_in_scene.png',0)
  
  kp1,des1 = surf.detectAndCompute(img1,None)
  kp2,des2 = surf.detectAndCompute(img2,None)
  
  
  bf = cv2.BFMatcher(cv2.NORM_L1,crossCheck=True)
  #I am planning to add more descriptors
  bf.add(des1)
  
  bf.train()
  
  #This is my test descriptor
  bf.match(des2)
  </code></pre>
  
  <p>The issue is with <code>bf.match</code> is that I am getting the following error:</p>
  
  <pre><code>OpenCV Error: Assertion failed (type == src2.type() &amp;&amp; src1.cols == src2.cols &amp;&amp; (type == CV_32F || type == CV_8U)) in batchDistance, file /build/opencv/src/opencv-3.1.0/modules/core/src/stat.cpp, line 3749
  Traceback (most recent call last):
    File "image_match4.py", line 16, in &lt;module&gt;
      bf.match(des2)
  cv2.error: /build/opencv/src/opencv-3.1.0/modules/core/src/stat.cpp:3749: error: (-215) type == src2.type() &amp;&amp; src1.cols == src2.cols &amp;&amp; (type == CV_32F || type == CV_8U) in function batchDistance
  </code></pre>
  
  <p>The error is similar to <a href="https://stackoverflow.com/questions/24224846/opencv-bfmatcher-match-always-return-error">this</a> post. The explanation given is incomplete and inadequate.I want to know how to resolve this issue. I have used ORB descriptors as well with BFMatcher having <code>NORM_HAMMING</code> distance. The error resurfaces.
  Any help will be appreciated.</p>
  
  <p>The two images that I have used for this are:</p>
  
  <p><a href="https://i.stack.imgur.com/Er7vx.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Er7vx.png" alt="box.png"></a></p>
  
  <p>box.png </p>
  
  <p><a href="https://i.stack.imgur.com/gAz96.png" rel="noreferrer"><img src="https://i.stack.imgur.com/gAz96.png" alt="box_in_scene.png"></a></p>
  
  <p>box_in_scene.png</p>
  
  <p>I am using Python 3.5.2 and OpenCV 3.1.x in linux.</p>