当前位置:   article > 正文

Opencv cv2 Python 安装教程_cv2包怎么安装

cv2包怎么安装

opencv是什么

OpenCV是一个基于Apache2.0许可(开源)发行的跨平台计算机视觉机器学习软件库,可以运行在Linux、Windows、AndroidMac OS操作系统上。OpenCV用C++语言编写,它具有C ++,PythonJavaMATLAB接口,,OpenCV主要倾向于实时视觉应用,并在可用时利用MMX和SSE指令, 如今也提供对于C#、Ch、Ruby,GO的支持。

 

想要了解更多,请查阅以下百科:

百度百科-验证百度百科是一部内容开放、自由的网络百科全书,旨在创造一个涵盖所有领域知识,服务所有互联网用户的中文知识性百科全书。在这里你可以参与词条编辑,分享贡献你的知识。https://baike.baidu.com/item/opencv/10320623?fr=ge_ala

安装cv2

在电脑里打开“命令提示符”cmd

输入以下代码:

  1. #cmd
  2. pip install opencv-python
  3. #或者是
  4. pip install opencv-contrib-python

运行代码:

  1. Defaulting to user installation because normal site-packages is not writeable
  2. Collecting opencv-contrib-python
  3. Downloading opencv_contrib_python-4.8.0.76-cp37-abi3-win_amd64.whl (44.8 MB)
  4. ---------------------------------------- 44.8/44.8 MB 68.3 kB/s eta 0:00:00
  5. Requirement already satisfied: numpy>=1.21.2 in c:\users\f'c\appdata\roaming\python\python311\site-packages (from opencv-contrib-python) (1.25.2)
  6. Installing collected packages: opencv-contrib-python
  7. Successfully installed opencv-contrib-python-4.8.0.76
  8. [notice] A new release of pip available: 22.3.1 -> 23.2.1
  9. [notice] To update, run: python.exe -m pip install --upgrade pip

 根据 “[notice] To update, run: python.exe -m pip install --upgrade pip” 的提示

输入代码:

  1. #cmd
  2. python.exe -m pip install --upgrade pip

运行代码:

  1. Defaulting to user installation because normal site-packages is not writeable
  2. Requirement already satisfied: pip in c:\program files\python311\lib\site-packages (22.3.1)
  3. Collecting pip
  4. Downloading pip-23.2.1-py3-none-any.whl (2.1 MB)
  5. ---------------------------------------- 2.1/2.1 MB 20.0 kB/s eta 0:00:00
  6. Installing collected packages: pip
  7. WARNING: The scripts pip.exe, pip3.11.exe and pip3.exe are installed in 'C:\Users\f'c\AppData\Roaming\Python\Python311\Scripts' which is not on PATH.
  8. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  9. Successfully installed pip-23.2.1

 安装完毕

检测cv2是否安装成功

输入程序:

  1. #Python
  2. import cv2
  3. print(cv2.__version__)

运行结果:

1.没有安装 
  1. Traceback (most recent call last):
  2. File "C:\Users\ \ \ \ .py", line 1, in <module>
  3. import cv2
  4. ModuleNotFoundError: No module named 'cv2'

这是报错的一种代码,反正报错就是安装错误。

2.成功安装
  1. 4.8.0
  2. Process finished with exit code 0

只要有一个像这样的版本号就行了,不一定要4.8.0的版本号,其他的也行。

希望能够帮助到您哦~

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/631505
推荐阅读
相关标签
  

闽ICP备14008679号