天天看點

Python 圖像處理篇-利用opencv庫和numpy庫讀取包含中文路徑下的本地圖檔執行個體示範

Python 圖像處理篇-利用opencv庫和numpy庫讀取包含中文路徑下的本地圖檔執行個體示範

很簡單,隻要用 numpy 把圖檔解碼一下就好了。

import cv2
import numpy as np

# img = cv2.imread("小愛.jpg")   # 直接讀取中文會報錯
img = cv2.imdecode(np.fromfile("小愛.jpg", dtype=np.uint8), 1)   # 可以讀取中文路徑圖檔
cv2.imshow("xiaoai", img)   # 展示圖檔時視窗顯示名稱
cv2.waitKey(10000)   # 圖像展示時間,機關:毫秒(ms)      

喜歡的點個贊❤吧!

繼續閱讀