Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cv2.imread always returns NoneType

Tags:

cv2.imread is always returning NoneType.

I am using python version 2.7 and OpenCV 2.4.6 on 64 bit Windows 7.

Maybe it's some kind of bug or permissions issue because the exact same installation of python and cv2 packages in another computer works correctly. Here's the code:

im = cv2.imread("D:\testdata\some.tif",CV_LOAD_IMAGE_COLOR) 

I downloaded OpenCV from http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv. Any clue would be appreciated.

like image 718
Tae-Sung Shin Avatar asked Jul 30 '13 14:07

Tae-Sung Shin


1 Answers

First, make sure the path is valid, not containing any single backslashes. Check the other answers, e.g. https://stackoverflow.com/a/26954461/463796.

If the path is fixed but the image is still not loading, it might indeed be an OpenCV bug that is not resolved yet, as of 2013. cv2.imread is not working properly under Win32 for me either.

In the meantime, use LoadImage, which should work fine.

im = cv2.cv.LoadImage("D:/testdata/some.tif", CV_LOAD_IMAGE_COLOR) 
like image 128
w-m Avatar answered Oct 14 '22 22:10

w-m