본문 바로가기
-------------코딩-------------/python 에러 모음

opencv imread error (경로 한글, 영어 섞여있음)

by 탶선 2022. 4. 14.
반응형
import cv2
import numpy as np

def isKorean(text):
    hangul = re.compile('[\u3131-\u3163\uac00-\ud7a3]+')  
    result = hangul.findall(text)
    if len(result) > 0:
        return True
    else:
        return False

if isKorean(file_path) == True:
    img = cv2.imread(file_path, cv2.IMREAD_COLOR)
    img = np.fromfile(file_path, np.uint8)
    img = cv2.imdecode(img, cv2.IMREAD_COLOR)
elif isKorean(file_path) == False:
    img = cv2.imread(file_path, cv2.IMREAD_COLOR)

 

함수로 해결

반응형

댓글