Home  >  Article  >  Backend Development  >  How to use Python's cv2 library and download the OpenCV library?

How to use Python's cv2 library and download the OpenCV library?

PHPz
PHPzforward
2023-04-24 21:55:141969browse

cv2 library is in the opencv library, so you need to download opencv-python
1. Open the windows command line:

win R
cmd

How to use Pythons cv2 library and download the OpenCV library?

2. Update pip version (not necessary):

python -m pip install --upgrade pip

How to use Pythons cv2 library and download the OpenCV library?

3. Use pip to download opencv:
It is best to download the numpy library before downloading the opencv library.
The mirror source of the University of Science and Technology of China is used here: https://pypi.mirrors.ustc.edu.cn/simple/

pip install numpy -i https://pypi.mirrors.ustc. edu.cn/simple/
pip install opencv-python -i https://pypi.mirrors.ustc.edu.cn/simple/

4. View the downloaded libraries and versions :

pip list

How to use Pythons cv2 library and download the OpenCV library?

5. Code application cv2:
Create a new .py file in Pycharm and write the code :

import cv2

The code does not report an error, basically you can use the opencv library.

How to use Pythons cv2 library and download the OpenCV library?

The above is the detailed content of How to use Python's cv2 library and download the OpenCV library?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete