[Python] Reading .exr files in OpenCV

Discussão em 'Python' iniciado por Stack, Fevereiro 14, 2025.

  1. Stack

    Stack Membro Participativo

    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]


    Error:

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


    and

    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.

    Continue reading...

Compartilhe esta Página