Whenever I try and use cv2.imread with a Multilayer EXR I get the below error. I’ve enabled the
File "E:\programming\opencv\tests\test.blend\Text.001", line 19, in <module>
cv2.error: OpenCV(4.6.0) D:\a\opencv-python\opencv-python\opencv\modules\imgcodecs\src\grfmt_exr.cpp:103: error: (-213:The function/feature is not implemented) imgcodecs: OpenEXR codec is disabled. You can enable it via 'OPENCV_IO_ENABLE_OPENEXR' option. Refer for details and cautions here: https://github.com/opencv/opencv/issues/21326 in function 'cv::initOpenEXR'
I’ve enabled the os option it mentions, but still kicks out the same error. Here’s my code. Any clues?
import os
os.environ["OPENCV_IO_ENABLE_OPENEXR"]="1"
import cv2
from cv2 import dnn_superres
# Create an SR object
sr = dnn_superres.DnnSuperResImpl_create()
# Read image
dir = 'E:/programming/opencv/tests'
models = 'E:/programming/opencv/models'
print(models)
PATH2EXR = f'{dir}/RL_4d3af479e067691982cb5c63ab7c2f08_0001.exr'
image = cv2.imread(PATH2EXR, cv2.IMREAD_ANYCOLOR | cv2.IMREAD_ANYDEPTH)
# Read the desired model
path = f'{models}/FSRCNN_x2.pb'
print(path)
sr.readModel(path)
# Set the desired model and scale to get correct pre- and post-processing
sr.setModel("fsrcnn", 2)
# Upscale the image
result = sr.upsample(image)
# Save the image
cv2.imwrite(f'{dir}/TEST.exr', result)