pycharm+anaconda配置
分别安装pycharm和anaconda
链接: pycharm官网 https://www.jetbrains.com/pycharm/download/#section=windows 安装社区版就好
链接:anaconda官网https://www.anaconda.com/products/individual#windows
安装时注意python版本信息,合理搭配
安装完后配置
打开pycharm 的设置界面 如此将anaconda库配置进pycharm中。
配置opencv
打开pycharm 复制下面一段代码
pip install opencv-contrib-python -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
即 如此出现 Successfully installed opencv-contrib-python-4.5.3.56 opencv安装成功 可以用一段代码测试
import cv2
import numpy as np
img = np.zeros((512,512,3),np.uint8)
cv2.line(img,(0,0),(img.shape[1],img.shape[0]),(0,255,0),3)
cv2.rectangle(img,(0,0),(250,350),(0,0,255),cv2.FILLED)
cv2.circle(img,(400,50),30,(255,255,0),5)
cv2.putText(img,"OPENCV ",(300,100),cv2.FONT_HERSHEY_COMPLEX,1,(0,150,0),1)
cv2.imshow("Image",img)
cv2.waitKey(0)
结果如图
|