1:安装
win + r输入cmd打开控制面板输入pip install opencv-contrib-python回车
2:使用
>>> import cv2
>>>img = cv2.imread(r'D:\BaiduNetdisk\daxian.jpg',0)#只允许英文路径
>>>> print(img.shape)
(2054, 3344)
>>> cv2.imshow('lenna',img)
>>> resized_img = cv2.resize(img,(int(img.shape[1]/2),int(img.shape[0]/2)))
>>> cv2.imshow('lenna_small',resized_img)
显示图片,读取键盘
import cv2
img = cv2.imread(r'D:\BaiduNetdisk\daxian.jpg',0)
cv2.imshow('lenna',img)
k = cv2.waitKey(0)
if k == 27:
cv2.destroyWindow('lenna')
elif k == 115:
cv2.imwrite(r'D:\BaiduNetdisk\lenna.jpg',img)
cv2.destroyWindow('lenna')