title: cv2.imread and os.listdir don't work
body: <p>I m trying to itterate through images in a folder for further processing. 
  I tried to read just one image in the folder using this code </p>
  
  <pre><code>import cv2  
  import os 
  
  img=cv2.imread('/home/hch/Desktop/Database/sample.jpg')
  print (img.shape)
  
  for filename in os.listdir('Database') :
      if filename.endswith(".jpg") :
          img=cv2.imread(filename)
          print (img.shape)
  </code></pre>
  
  <p>As you can see the fist part reads the image directly while the second tries to read it through <code>os.listdir</code>. </p>
  
  <p>The problem is that the second part doesn't work it. it gives me this message  : </p>
  
  <pre><code>Traceback (most recent call last):
    File "resize.py", line 10, in &lt;module&gt;
      print (img.shape)
  AttributeError: 'NoneType' object has no attribute 'shape'
  </code></pre>
  
  <p>And when I print filename it prints the name of the image " sample.jpg".</p>
  
  <p>Can you help me understand why it doesn't work ?</p>
  
  <p>Thank you </p>