Trouble/Vision 14

import cv2 시 'numpy._DTypeMeta' object is not subscriptable 오류

pip install opencv-python으로 cv2 설치하는 것은 아주 간단한데, 설치하고 나서 다음 오류가 떴다. Traceback (most recent call last): File "/home/jseob/Desktop/yjs/codes/3DDFA_V2/demo.py", line 7, in import cv2 File "/home/jseob/anaconda3/envs/face/lib/python3.9/site-packages/cv2/__init__.py", line 181, in bootstrap() File "/home/jseob/anaconda3/envs/face/lib/python3.9/site-packages/cv2/__init__.py", line 175, in bootstrap if..

Trouble/Vision 2023.09.04

이미지가 일부가 깨져 열리지 않는 문제 : image file is truncated

이미지 파일이 잘 존재하고 뷰어로는 잘 열리는 상황에서도 opencv cv2.imread로 이미지가 읽히지 않는 현상이 있다. 결론부터 말하면 이미지 파일이 손상되어있는 것이 원인인데 뷰어에서는 열리므로 약간 손상되어있는 것이다. 자세히 보면 아래 사진처럼 뷰어에서 일부가 회색으로 보일 것이다. 이미지가 실제로 (128, 128, 128)을 갖는 것이 아니라 pixel에 값이 존재 하지 않는 것이다. 문제 상황 check0 = os.path.exists(img_path) # True check1 = os.path.isfile(img_path) # True cvimg = cv2.imread(img_path) # None pilimg = Image.open(img_path) # image file is tr..

Trouble/Vision 2023.08.25

cv2.fisheye 사용 시 error: (-215:Assertion failed) objectPoints.type() == CV_32FC3 || objectPoints.type() == CV_64FC3 in function 문제

cv2.error: OpenCV(4.7.0) /io/opencv/modules/calib3d/src/fisheye.cpp:77: error: (-215:Assertion failed) objectPoints.type() == CV_32FC3 || objectPoints.type() == CV_64FC3 in function 'projectPoints' cv2.fisheye를 쓸 일이 드물긴 하지만 가끔 어쩌다 쓸 때 위와 같은 오류를 자주 볼 수 있다. 오류명만 봐서는 사용하는 변수 타입이 float64, flaot32 중 하나로 통일이 안되어있단 뜻 같은데 타입을 맞춰도 오류가 해결되지 않기 때문에 조금 귀찮다. 그 경우 대부분 objectPoints 즉, 사용하는 3D point의 shape이 잘못되..

Trouble/Vision 2023.06.27

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.

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 파일일 경우, 위와 같은 오류가 ..

Trouble/Vision 2023.02.20