cv2.imread 总是返回 NoneType [英] cv2.imread always returns NoneType

查看:44
本文介绍了cv2.imread 总是返回 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:	estdatasome.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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆