like the title says I want to read .exr image files which encode depth.
Sample image - displayed using openexr-viewer (Source: Synscapes datatset)
I tried:
os.environ["OPENCV_IO_ENABLE_OPENEXR"]="1"
import cv2
import numpy as np
exr_file_path = 'path/to/file'
image = cv2.imread(exr_file_path, cv2.IMREAD_ANYCOLOR | cv2.IMREAD_ANYDEPTH)
The dimensions of image are correct, but the image is completely filled with zeros.
Debugger shows this:
->image.shape
(720, 1440)
->np.unique(image)
array([0.], dtype=float32)
What am I missing ?
My goal would be to create a function which accepts a path to an .exr file and returns the image as a pillow image.
Currently this is what I have:
def exr_to_pil(exr_file_path):
exr_file_path = str(exr_file_path)
image = cv2.imread(exr_file_path, cv2.IMREAD_ANYCOLOR | cv2.IMREAD_ANYDEPTH)
# Debugger stops here to check output of imread
img = Image.fromarray(image.astype('uint8'))
return img
Solved the problem using the OpenEXR an Imath libs
At first had some problems installing OpenEXR but could fix is thanks to this answer in this post.
Code for depth map loading is: