cv2.imread와 cv2.imwrite를 사용하면 한글 경로를 인식하지 못하는 오류가 발생. 바이트 형태의 배열로 읽어와 numpy array로 다시 변환하여 cv2.imdecode로 읽어온다.
저장 시에는 cv2.imencode를 이용하여서 저장. def imread(path_file,flag = cv2.IMREAD_COLOR,dtype = np.uint8): stream = open(path_file,"rb") bytes = bytearray(stream.read()) numpyarray = np.asanyarray(bytes,dtype = dtype) bgrImage = cv2.imdecode(numpyarray,flag) return bgrImage def imwrite(path_file,img,params = None): ext = os.path.splitext(path_file)[1] result, n = cv2.imencode(ext, img, params) if r...
원문 링크 : Python) Opencv 한글 경로 인식 문제