Created
January 18, 2019 13:31
-
-
Save Jojozzc/f0612d13f68562dbdf92454aa8f5abdc to your computer and use it in GitHub Desktop.
fix ZH path bug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import cv2 | |
import os | |
def cv2_imread(filename, mode=-1): | |
# 0:gray | |
# 1:rgb | |
# -1 any, read as the mode of source itself. | |
# like cv2.imread | |
cv_img = cv2.imdecode(np.fromfile(filename, dtype=np.uint8), mode) | |
return cv_img | |
def cv2_imwrite(filename, img, suffix=None): | |
# like cv2.imwrite | |
if suffix is None: | |
suffix = os.path.splitext(filename)[-1] | |
if suffix == '': | |
suffix = '.png' | |
cv2.imencode(suffix, img)[1].tofile(filename) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Support Chinese path
支持中文路径