1.在cmd中输入pip install opencv-python;

2.在pycharm->文件->设置...->Project Interpreter->添加python.exe(有两个路径:在D:\anaconda3\python.exe或者在D:\pyCharmfiles\venv\Scripts\python.exe)->

 3.尝试运行代码

# -*- coding: utf-8 -*-

import cv2
img = cv2.imread('D:/study/eyeCalibration/minewritten/1.png', cv2.IMREAD_GRAYSCALE)  # 读入彩色图片
cv2.imshow('image', img)  # 建立image窗口显示图片
k = cv2.waitKey(0)  # 无限期等待输入

if k == 27:  # 如果输入ESC退出
    cv2.destroyAllWindows()

elif k == ord('s'):
    cv2.imwrite('test.png', img)
    print("OK!" )
    cv2.destroyAllWindows()

pycharm中cv2模块的安装

相关文章:

  • 2021-09-05
  • 2022-12-23
  • 2022-12-23
  • 2021-05-29
  • 2021-11-29
  • 2022-12-23
  • 2021-05-30
  • 2021-11-20
猜你喜欢
  • 2022-12-23
  • 2021-07-18
  • 2021-04-25
  • 2022-01-12
  • 2021-04-03
  • 2021-08-15
  • 2021-05-28
相关资源
相似解决方案