Search code examples
pythonopencvimread

imread always return "None"


I am struggling to read a picture from certain directory.

img = cv2.imread('/Users/myname/Desktop/traindog.8011.jpg', cv2.IMREAD_COLOR) 
print (img)

I just simplified my code to make sure the issue and understand above. And even when I put the full path of the picture, it always returns 'None'. Where did I get a wrong ? Thank you in advance.


Solution

  • try this:

    img = cv2.imread('\Users\myname\Desktop\traindog.8011.jpg', cv2.IMREAD_COLOR) 
    

    or

    img = cv2.imread('//Users//myname//Desktop//traindog.8011.jpg', cv2.IMREAD_COLOR)