Trouble/OpenCV

cv2.error: OpenCV(4.5.5) /io/opencv/modules/imgcodecs/src/grfmt_exr.cpp:103: error: (-213:The function/feature is not implemented) imgcodecs: OpenEXR codec is disabled.

침닦는수건 2023. 2. 20. 17:58
반응형
cv2.error: OpenCV(4.5.5) /io/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 'initOpenEXR'

 

Opencv로 depth 이미지를 다룰 때 depth 이미지의 확장자가 .exr 파일일 경우, 위와 같은 오류가 날 수 있다. 

 

.exr 파일은 기본적으로 opencv가 다루는 포맷이 아니어서 별도로 exr 파일 포맷을 사용한다고 enable 시켜주어야 한다.

 

os.environ["OPENCV_IO_ENABLE_OPENEXR"]="1"

코드 상단에 위 설정을 추가해주면 된다.

 

추가적으로, 다음과 같은 오류명도 자주 같이 보이는데 이는 저장할 때 확장자를 .exr로 써서 그렇다. 

cv2.error: OpenCV(4.5.5) /io/opencv/modules/imgcodecs/src/loadsave.cpp:742: error: (-215:Assertion failed) encoder->isFormatSupported(CV_8U) in function 'imwrite_'

exr 확장자가 흔하지 않으니, 읽을 때는 데이터가 exr 파일로 저장된 것이니 어쩔 수 없다지만 저장할 때는 uint16으로 변환해서 png로 저장하는 것이 좋다. 

 

opencv로 depth 이미지 저장할 때 .exr 확장자로 저장하지 말자.

반응형