Skip to content

Instantly share code, notes, and snippets.

@Jojozzc
Created January 18, 2019 13:31
Show Gist options
  • Save Jojozzc/f0612d13f68562dbdf92454aa8f5abdc to your computer and use it in GitHub Desktop.
Save Jojozzc/f0612d13f68562dbdf92454aa8f5abdc to your computer and use it in GitHub Desktop.
fix ZH path bug
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)
@Jojozzc
Copy link
Author

Jojozzc commented Mar 10, 2019

Support Chinese path
支持中文路径

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment