title: Error: (-5) image is empty or has incorrect depth (!=CV_8U) in function detectAndCompute
body: <p>I get a problem but I don't understand why it doesn't work.
  I'm working on <code>MacOSX Sierra</code> and I'm using <code>Python 2.7</code> and <code>OpenCV 3.1</code>.</p>
  
  <p>It's a very simple script :</p>
  
  <pre><code>import numpy as np
  import cv2
  #from matplotlib import pyplot as plt
  
  #########################
  # SIFT descriptors part #
  #########################
  
  img1 = cv2.imread('/Users/valentinjungbluth/Desktop/SIFT:SURF Algo/lampe.jpg',0)
  img2 = cv2.imread('/Users/valentinjungbluth/Desktop/SIFT:SURF Algo/ville.jpg',0)
  
  #img1 = cv2.cvtColor(IMG1, cv2.COLOR_BGR2GRAY)
  #img2 = cv2.cvtColor(IMG2, cv2.COLOR_BGR2GRAY)
  
  # Initiate SIFT detector
  sift = cv2.xfeatures2d.SIFT_create()
  
  print (img1.dtype)
  
  kp1, des1 = sift.detectAndCompute(img1,None)
  kp2, des2 = sift.detectAndCompute(img2,None)
  
  bf = cv2.BFMatcher()
  matches = bf.knnMatch(des1,des2,k=2)
  
  good = []
  for m,n in matches :
      if m.distance &lt; 0.75*n.distance :
          godd.append([m])
  
  img3 = cv2.drawMatchesKnn(img1,kp1,img2,kp2,good,flags=2)
  
  #kp = sift.detect(gray,None)
  #img = cv2.drawKeypoints(gray,kp,img)
  
  cv2.imwrite('matches.jpg',img3)
  </code></pre>
  
  <p>But when I run the script in the terminal, I get exactly this error :</p>
  
  <pre><code>(cv) MacBook-Pro-de-Valentin:SIFT:SURF Algo valentinjungbluth$ python image.py 
  uint8
  OpenCV Error: Bad argument (image is empty or has incorrect depth (!=CV_8U)) in detectAndCompute, file /Users/valentinjungbluth/opencv_contrib/modules/xfeatures2d/src/sift.cpp, line 770
  Traceback (most recent call last):
    File "image.py", line 22, in &lt;module&gt;
      kp2, des2 = sift.detectAndCompute(img2,None)
  cv2.error: /Users/valentinjungbluth/opencv_contrib/modules/xfeatures2d/src/sift.cpp:770: error: (-5) image is empty or has incorrect depth (!=CV_8U) in function detectAndCompute
  </code></pre>
  
  <p>The <code>dtype</code> is <code>uint8</code> so I don't understand why I get this error.
  If someone could help me ?</p>
  
  <p>Thank you so much !</p>