일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 오블완
- 백신후원
- Multi-Resolution Networks for Semantic Segmentation in Whole Slide Images
- 도커
- docker attach
- CellPin
- docker
- 코크리
- numpy
- logistic regression
- 사회조사분석사2급
- docker exec
- ssh
- WSSS
- GIT
- cocre
- Jupyter notebook
- 프로그래머스
- AIFFEL
- 티스토리챌린지
- Decision Boundary
- vscode
- 기초확률론
- airflow
- HookNet
- Pull Request
- aiffel exploration
- cs231n
- 히비스서커스
- IVI
Archives
- Today
- Total
히비스서커스의 블로그
[OpenCV] error: OpenCV(4.5.4) /tmp/pip-req-build-sokf1_ny/opencv/modules/imgcodecs/src/loadsave.cpp:728: error: (-2:Unspecified error) could not find a writer for the specified extension in function 'imwrite_' 본문
Programming/Python
[OpenCV] error: OpenCV(4.5.4) /tmp/pip-req-build-sokf1_ny/opencv/modules/imgcodecs/src/loadsave.cpp:728: error: (-2:Unspecified error) could not find a writer for the specified extension in function 'imwrite_'
HibisCircus 2021. 12. 21. 17:36728x90
상황
cv2.imwrite()를 쓰는 상황에서 에러가 발생하였다.
대략적인 코드
import numpy as np
import cv2
name = 'sample_001.svs'
mask = np.zeors((512,512), dtype=np.uint8)
cv2.imwrite(f'../test_inference/results/{name[-7:-4]}/{name}', mask)
에러 메세지
error: OpenCV(4.5.4) /tmp/pip-req-build-sokf1_ny/opencv/modules/imgcodecs/src/loadsave.cpp:728: error: (-2:Unspecified error) could not find a writer for the specified extension in function 'imwrite_'
원인
cv2.imwrite()안의 저장하는 파일명에서 확장자명이 정상적이지 않았기 때문
해결방법
cv2.imwrite()안의 저장하는 파일명에서 확장자명을 정상적으로 바꿔준다. (ex. .jpg or .png 등등)
수정된 코드
import numpy as np
import cv2
name = 'sample_001.svs'
mask = np.zeors((512,512), dtype=np.uint8)
cv2.imwrite(f'../test_inference/results/{name[-7:-4]}/{name[:-4].png}', mask)
잘 해결되었다.
- 히비스서커스 -
728x90