OpenCV-Python的安装和测试

xiaohai 2023-07-02 08:03:53 1576人围观 标签: Opencv 
简介OpenCV-Python是OpenCV的Python API,集成了Python语言和C++语言的最优特征,致力于支持Python解决计算机视觉问题。本节主要介绍OpenCV-Python的安装.

安装OpenCV-Python首先要安装Python环境,也可以直接安装anaconda环境。我这里还是使用单独的Python环境

1、下载Python安装包

https://www.python.org/downloads/

我使用的是windows环境,所以下载对应的安装包,双击安装即可。

C:\Users\xxx>python
Python 3.11.4 (tags/v3.11.4:d2340ef, Jun  7 2023, 05:45:37) [MSC v.1934 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
2、安装OpenCV-Python
pip install opencv-python
3、测试

在命令行中输入:import cv2,没有报错就说明安装成功了.

C:\Users\xxx>python
Python 3.11.4 (tags/v3.11.4:d2340ef, Jun  7 2023, 05:45:37) [MSC v.1934 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>>

至此,OpenCV-Python就安装完成.