简体   繁体   English

cv2.imread始终返回None类型-使用cv虚拟环境

[英]cv2.imread always returns None type - using cv virtual environment

I am using a virtual environment, which I called cv. 我正在使用一个称为cv的虚拟环境。 I am trying to read into a numpy array using opencv a .cr2 raw image. 我正在尝试使用.c2原始图像使用opencv读取一个numpy数组。

Using: 使用方法:

import cv2
img = cv2.imread("raw.cr2")
print img

Returns: 返回值:

None

Always. 总是。

I believe the problem is in the path of raw.cr2 , which cannot be found apparently. 我相信问题出在raw.cr2的路径上,显然找不到该路径。 I have tried including the absolute path in the file I pass to imread. 我尝试将绝对路径包含在要传递的文件中。 My file is in the home folder (~) where I run python from. 我的文件位于运行python的主文件夹(〜)中。 I know the path is the issue because if I run sys.os.exists(path) , it always returns False . 我知道路径是问题所在,因为如果我运行sys.os.exists(path) ,它将始终返回False

Lastly, I also tried reading raw.cr2 using scipy.misc: 最后,我也试着阅读raw.cr2使用scipy.misc:

img = scipy.misc.imread(path)

Returns: 返回值:

IOError: cannot identify image file 'raw.cr2'

Don't know if you ever solved this. 不知道您是否解决了这个问题。 I recently encountered the same problem (using ArchLinux) and found it was a permissions issue. 我最近(使用ArchLinux)遇到了同样的问题,发现这是一个权限问题。 Had to chown the images I wanted to use. 必须对我想使用的图像进行整理。 Silly me. 傻我

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM