cv2.imread始终返回NoneType [英] cv2.imread always returns NoneType
问题描述
cv2.imread
始终返回NoneType
.
我在64位Windows 7上使用python版本2.7和OpenCV 2.4.6.
I am using python version 2.7 and OpenCV 2.4.6 on 64 bit Windows 7.
也许是某种错误或权限问题,因为在另一台计算机上安装完全相同的python和cv2软件包可以正常工作.这是代码:
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)
我从 http://www.lfd.uci.edu/下载了OpenCV 〜gohlke/pythonlibs/#opencv .任何线索将不胜感激.
I downloaded OpenCV from http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv. Any clue would be appreciated.
推荐答案
首先,确保路径有效,且不包含任何单个反斜杠.检查其他答案,例如 https://stackoverflow.com/a/26954461/463796 .
First, make sure the path is valid, not containing any single backslashes. Check the other answers, e.g. https://stackoverflow.com/a/26954461/463796.
如果路径是固定的,但图像仍未加载,则可能确实是 OpenCV错误(截至2013年)仍未解决.对我来说cv2.imread
在Win32下也无法正常工作.
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.
同时,使用LoadImage,它应该可以正常工作.
In the meantime, use LoadImage, which should work fine.
im = cv2.cv.LoadImage("D:/testdata/some.tif", CV_LOAD_IMAGE_COLOR)
这篇关于cv2.imread始终返回NoneType的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!