opencv c++是支持中文的,
opencv python不支持的情况:
1.路径中含有中文。
2.路径中含有特殊字符,比如π
读取图片
img = cv2.imdecode(np.fromfile(img_path, dtype=np.uint8), 1)
img
=
cv2.imdecode(np.fromfile(img_path, dtype
=
np.uint8),
-
1
)
# 读入完整图片,见下面解释
img
=
cv2.imdecode(np.fromfile(img_path, dtype
=
np.uint8),
0
)
# 读成灰度
img
=
cv2.imdecode(np.fromfile(img_path, dtype
=
np.uint8),
1
)
# 读成彩图
其中:img_path为读取图片路径及图片名,可以包含中文
保存图片
cv2.imencode('.jpg', src)[1].tofile(save_path)