Hi, I am using imread to read .exr images as
img = cv2.imread(img_path, cv2.IMREAD_ANYCOLOR | cv2.IMREAD_ANYDEPTH)
which works most of the time, but sometime randomly it fails with the following error
imread_('filename.exr'): can't read data: unknown exception
I have tried looping over all images multiple times and reading them. Sometimes I am able to read all images without any error, and sometime I get such errors. Any idea why this may be happening or any way I can try and fix this.
possible bug. what version of OpenCV do you use? can you provide a minimal reproducible example, including sample data?
I am as of this month experiencing the same problem with code that was working before.
I am on:
$ conda list | grep opencv
opencv-python 4.5.4.60 pypi_0 pypi
opencv-python-headless 4.5.4.60 pypi_0 pypi
$ python -V
Python 3.8.8
I cv2.imwrite
and cv2.imread
thousands of .exr
files.
I have found that I can sometimes write retry logic that checks if the return from cv2.imread
is None
and read again successfully. I have also found cases where this doesn’t work. I have found that when I have a file that is never successfully read with cv2.imread
I also fail to open that file with Gimp, unlike one of my normal files.
I recently added a check where on the line immediately following cv2.imwrite
I attempt a cv2.imread
and have had that read fail. I have been wondering if I have a failing drive.
I should follow-up to say that I ended up swapping out my RAM And this problem went away. In hindsight my system was suffering other issues related to that bad RAM.