한 번만 더 해보자

[Python] cv2 경로의 한글 깨짐 본문

언어/Python

[Python] cv2 경로의 한글 깨짐

정 하임 2023. 9. 22. 20:30

상황

cv2로 이미지를 읽으려고 하는데 경로의 한글이 깨져서 인식이 안됨

 

 

에러코드

[ WARN:0@1.994] global loadsave.cpp:244 cv::findDecoder imread_('C:/Users/Desktop/test/images\\媛뙋_媛濡쒗媛_1462.JPG'): can't open/read file: check file path/integrity
Traceback (most recent call last):
  File "c:\\DEV\\python\\image_warping.py", line 43, in <module>
    w = img.shape[1]
AttributeError: 'NoneType' object has no attribute 'shape'

 

 

 

해결 방법

import numpy as np
import cv2

image_path = "C://image/path/이미지_이름.jpg"
img_array = np.fromfile(image_path, np.uint8)
img = cv2.imdecode(img_array, cv2.IMREAD_COLOR)
반응형