Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- YOLO
- JSON
- pip
- pandas
- label
- Visual Studio
- Linux
- VS Code
- 핑거스타일
- Numpy
- error
- Python
- C#
- paramiko
- Selenium
- C
- OpenCV
- C++
- windows forms
- 채보
- 오류
- SSH
- 기타 연주
- pytorch
- 프로그래머스
- mysql
- 컨테이너
- ubuntu
- Docker
- nvidia-smi
Archives
- Today
- Total
기계는 거짓말하지 않는다
Python OpenCV imread, imwrite 한글 문제 본문
cv2를 이용할 때 imread, imwrite 한글(utf-8) 인식 문제가 있다.
imread, imwrite 함수를 아래와 같이 선언하고 사용한다.
import os
import cv2
import numpy as np
def imread(file_path):
npArr = np.fromfile(file_path, dtype=np.uint8)
return cv2.imdecode(npArr, cv2.IMREAD_COLOR)
def imwrite(file_path, img, params=None):
try:
ext = os.path.splitext(file_path)[1]
result, n = cv2.imencode(ext, img, params)
if result:
with open(file_path, mode='w+b') as f:
n.tofile(f)
return True
else:
return False
except Exception as e:
print(e)
return False
'Python' 카테고리의 다른 글
Python 절대, 상대 경로 변환 (0) | 2022.12.03 |
---|---|
Python 추상 클래스 (Abstract Class) (0) | 2022.12.03 |
Python String 문자 수정(Modify) (0) | 2022.11.25 |
List remove 반복 활용 없이 필요한 값만 남기고 제거 (0) | 2022.11.18 |
OpenCV video read 시 프레임 회전 문제 (0) | 2022.11.04 |
Comments