在OpenCV中读取.exr文件 [英] Reading .exr files in OpenCV

查看:648
本文介绍了在OpenCV中读取.exr文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Blender生成了一些深度图,并以OpenEXR格式保存了z缓冲区值(32位).有什么方法可以使用OpenCV 2.4.13和python 2.7访问.exr文件中的值(逐像素深度信息)?在任何地方都找不到示例.我在文档中看到的所有内容都支持该文件格式.但是尝试读取此类文件会导致错误.

I have generated some depth maps using blender and have saved z-buffer values(32 bits) in OpenEXR format. Is there any way to access values from a .exr file (pixel by pixel depth info) using OpenCV 2.4.13 and python 2.7? There is no example anywhere to be found. All I can see in documentation that this file format is supported. But trying to read such a file results in error.

new=cv2.imread("D:\\Test1\\0001.exr")
cv2.imshow('exr',new)
print new[0,0]

错误:

print new[0,0]
TypeError: 'NoneType' object has no attribute '__getitem__'

cv2.imshow('exr',new)
cv2.error: ..\..\..\..\opencv\modules\highgui\src\window.cpp:261: error: (-215) size.width>0 && size.height>0 in function cv::imshow

我找到的最近的是这个链接和这个

Closest I found is this link and this link.

推荐答案

我参加聚会可能有点晚了,但是; 是的,您绝对可以使用OpenCV.

I might be a little late to the party but; Yes you can definitely use OpenCV for that.

cv2.imread(PATH_TO_EXR_FILE,  cv2.IMREAD_ANYCOLOR | cv2.IMREAD_ANYDEPTH)  

应该为您提供所需的东西

should get you what you need

这篇关于在OpenCV中读取.exr文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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