opencv-python教程

1、安装python

网址:

官网:Welcome to Python.org​​​​​​​​​​​​​​​​​The official home of the Python Programming Languagehttps://www.python.org/我安装的是python3.11.4

安装时把环境路径勾选上,或者后面自己重新设置环境变量

2、下载opencv-python

按住win+R键,输入cmd,进入命令行界面

输入:pip install opencv-python

注:不要在命令行进入python环境后再输入上面的代码,会报错,我就犯了这个错误

查看opencv安装位置

pip show opencv-python

查看opencv版本

进入命令行界面,输入python,进入python环境,导入import cv2,输入cv2.__version__

安装vscode

网址:官网:​​​​​​https://code.visualstudio.com/Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications.  Visual Studio Code is free and available on your favorite platform - Linux, macOS, and Windows.https://code.visualstudio.com/Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications.  Visual Studio Code is free and available on your favorite platform - Linux, macOS, and Windows.https://code.visualstudio.com/

vscode安装中文简体包(我英文很差),安装python包

显示图片:

import cv2 as cv
mypath = "C:\\Desktop\\opencv_python\\open_learn\\kit.jpeg"
img = cv.imread(mypath,1)
cv.imshow("img",img)
cv.waitKey(0)
cv.destroyAllWindows()

 注:1、路径用"\\",而不是"\",否则会报错

        2、确保路径正确,文件名后缀不要写错

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值