cv2.imwrite(),cv2.imread()涉及中文路徑

imwrite()

原先代碼

cv2.imwrite(path_name, image)

但是path_name中含有中文,程序能夠運行但是此路徑文件夾仍爲空

這時應將代碼改成

cv2.imencode('.jpg',image)[1].tofile(path_name)

imread()

原先代碼

img = cv2.imread(path_name)

若path_name中含中文則改成

img=cv2.imdecode(np.fromfile(path_name,dtype=np.uint8),-1)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章