本文是最新的opencv-python 安装教程。
以前的一键安装 pip install opencv-python
在新版本上并不能使用。本文会按照4步详细的介绍。
opencv-python 版本:4.4.0
Python 版本: 3.9
第一步:
打开cmd,进入到你的pip.exe 所在位置,
即在你的python 安装路径里找到scripts文件夹,
比如我的路径是:
C:\Users\15162\AppData\Local\Programs\Python\Python39\Scripts
(不知道怎么寻找python安装路径可以上网查一下,有很多教程)
在这里插入图片描述

然后,升级你的pip 模块:
即在后面输入命令 pip install --upgrade pip 即可,按回车键,
在这里插入图片描述
安装好后会提示你安装成功。

第二步:
安装: wheel 包
(wheel 包是一种类似于zip 格式的文件,此次安装wheel 模块,是为了后面安装opencv-python4.4.0.whl 做准备)
在cmd 的Python 安装路径Scripts下输入 pip install wheel 即可,按回车键,会自动安装。
在这里插入图片描述
安装好后会提示你安装成功。

第三步:
安装 numpy 包
(numpy 包是一种科学计算的包,里面有很多包含矩阵,傅里叶变换,其他的很多计算,详情请百度下,本文只作简单介绍,这个包很有用,一定要安装)
在cmd 的Python 安装路径Scripts下输入pip install numpy 即可,按回车键,会自动安装。
在这里插入图片描述
安装好后会提示你安装成功。

第四步:
安装opencv-python。
打开一个免费分享链接:
https://www.lfd.uci.edu/~gohlke/pythonlibs/
然后找到
OpenCV: a real time computer vision library. 这一模块。
在这里插入图片描述

根据你的Python 版本和CPU位数安装,比如说我的Python 版本是 3.9,CPU 是64位,我选择了第一行:
opencv_python‑4.4.0‑cp39‑cp39‑win_amd64.whl
(cp39 指CPython 3.9, amd64 指64位)
安装好后,把这个压缩包剪切到你的Scripts 文件夹中:
在这里插入图片描述
在cmd 的Python 安装路径Scripts下输入
pip3.9.exe install C:\Users\15162\AppData\Local\Programs\Python\Python39\Scripts\opencv_python-4.4.0-cp39-cp39-win_amd64.whl

在这里插入图片描述
pip 模块一定要符合你的Python 版本,比如说我的版本是Python 3.9,那么我就要选择pip3.9.exe,这个之前升级pip 后就自动安装好。
install 后面的是opencv-python 安装包的绝对路径,即
C:\Users\15162\AppData\Local\Programs\Python\Python39\Scripts\opencv_python-4.4.0-cp39-cp39-win_amd64.whl
按回车键,会显示安装成功。

最后一步:验证opencv-python 和numpy是否安装成功:
新建一个Python 工程:

在这里插入图片描述
按照上图输入代码即可,其中

C:\\Users\\15162\\AppData\\Local\\Programs\\Python\\Python39\\Scripts\\1.jpg 

是案例图片的绝对路径。
至此,opencv-python 和numpy 安装完成。

GitHub 加速计划 / opencv31 / opencv
216
19
下载
OpenCV: 开源计算机视觉库
最近提交(Master分支:4 天前 )
5b1d3255 build: fix OpenBLAS cmake search 9 小时前
a7943cef features2d: performance optimization of detect function on Windows-ARM64 #27776 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - This PR improves the performance of the detect function on Windows ARM64 targets. - Added the defined(_M_ARM64) macro in agast.cpp and agast_score.cpp files, aligning ARM64 behavior with how x64 selects internal functions for computation. - As a result, ARM64 now executes the same internal functions as x64 where applicable, leading to measurable performance improvements in detect function. - This changes is limited to Windows ARM64 and does not affect other architectures **Performance impact:** - Detect function shows improved runtime on ARM64 targets due to reuse of existing efficient computation paths. <img width="1419" height="408" alt="image" src="https://github.com/user-attachments/assets/feab411a-d256-4bff-bec2-22b2583f63d1" /> 12 小时前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐