We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No description provided.
The text was updated successfully, but these errors were encountered:
解决方法:
1、读取 imread
def cv_imread(file_path): cv_img = cv2.imdecode(np.fromfile(file_path, dtype=np.uint8), -1) return cv_img
通过numpy读取文件,再编码为cv2的图片对象,避免了OpenCV不支持中文路径的问题。调用时,替换cv2.imread即可:
# img = cv2.imread(curimg_path) img = cv_imread(curimg_path)
2、保存 imwrite
同样地,图片输出到含有中文的路径也需要使用一个小函数:
def cv_imwrite(img, path): suffix = os.path.splitext(path)[-1] cv2.imencode(suffix, img)[1].tofile(path)
调用时,替换cv2.imwrite即可:
# cv2.imwrite(path, img) cv2_imwrite(img, path)
参考:https://heary.cn/posts/OpenCV-%E4%B8%AD%E6%96%87%E8%B7%AF%E5%BE%84%E9%97%AE%E9%A2%98/
Sorry, something went wrong.
No branches or pull requests
No description provided.
The text was updated successfully, but these errors were encountered: