Mac-pycharm安装cv2

1.左上角preferences...      Mac-pycharm安装cv2_第1张图片

2.如图所示点击鼠标所在位置的加号Mac-pycharm安装cv2_第2张图片

3.搜索框输入opencv,然后选择opencv-python,之后点击左下角Install Package

搜索框输入numpy,选择numpy,然后左下角安

Mac-pycharm安装cv2_第3张图片

4.输入简单的demo,运行(下面给出代码)

Mac-pycharm安装cv2_第4张图片

import numpy as np
import cv2

path = 'picture/dragon.jpeg'
new_path = 'picture/dragon_grey.jpeg'

img = cv2.imread(path, 0)
cv2.imshow(path, img)

k = cv2.waitKey(0)

if k == 27:# wait for ESC key to exit
    cv2.destroyAllWindows()
elif k == ord('s'): # wait for 's' key to save and exit
    cv2.imwrite(new_path, img)
    cv2.destroyAllWindows()

你可能感兴趣的:(opencv,python,numpy)