[오류]can't open/read file: check file path/integrity, cv2.Imread 못읽어올때

lena_log·2022년 5월 9일
1

오류 원인


cv2.imread가 파일 경로 안에 있는 '문서'라는 한글을 읽어오지 못하고 에러를 내보냄

오류

[ WARN:0@1.828] global D:\a\opencv-python\opencv-python\opencv\modules\imgcodecs\src\loadsave.cpp (239) cv::findDecoder imread_('C:/Users/kimsu/OneDrive/臾몄꽌/GitHub/-/ImagesAttendance/Bill_Gates.jpg'):
can't open/read file: check file path/integrity

해결 방법

cv2.imread를 바로 쓰지 않고
경로를 np.fromfile로 np.uint8로 컴퓨터가 읽을수 있게 만들어 준 다음
cv2.imdecode로 이미지 파일을 가져온다


path = 'C:/Users/kimsu/OneDrive/문서/GitHub/-/ImagesAttendance'
images = []

for cl in myList:
    full_path = path+'/'+cl #경로 전체를 가져오고
    img_array = np.fromfile(full_path, np.uint8) # 컴퓨터가 읽을수 있게 넘파이로 변환
    curImg = cv2.imdecode(img_array,  cv2.IMREAD_COLOR) #이미지를 읽어옴
    images.append(curImg)
profile
안녕하세요. 기억보다 기록을 믿는 레나입니다!

1개의 댓글

comment-user-thumbnail
2022년 5월 20일

opencv 는 한글 인식이 안 되죠 오류나면 한참 있다가 '아 한글 들어갔구나' 하면서 수정하네요

답글 달기