pip install opencv-python


foreword

The full name of OpenCV is Open Source Computer Vision Library, which is a cross-platform computer vision library. OpenCV is initiated and participated in the development by Intel Corporation. It is released under the BSD license and can be used free of charge in commercial and research fields. OpenCV can be used to develop real-time image processing, computer vision, and pattern recognition programs. The library can also use Intel's IPP for accelerated processing.


1. Basic concepts

opencv-python is a prebuilt CPU-only OpenCV package for Python.
If you wish to compile bindings from source to enable additional modules (e.g. CUDA), please check the manual building section.

2. Operation steps

1. Delete the old version

If you have a previous/other manually installed version of OpenCV installed, remove it before installing to avoid conflicts

pip uninstall opencv-python

2. pip upgrade

Make sure your pip version is up to date

pip install --upgrade pip

3.opencv-python installation

Choose one of the following options to install:

  1. Packages for standard desktop environments (Windows, macOS, almost any GNU/Linux distribution)

Option 1 - main module package: pip install opencv-python
Option 2 - full package (contains main module and contrib/extra modules): pip install opencv-contrib-python(check OpenCV documentation for list of contrib/extra modules)

  1. Packages for server (headless) environments like Docker, cloud environments, etc., no GUI library dependencies

These packages are smaller than the other two packages above because they don't contain any GUI functionality (not compiled with Qt/other GUI components). This means that these packages avoid heavy dependency chains to X11 libraries, so you'll have e.g. smaller Docker images. You should always use these packages if you are not using cv2.imshow etc. Or you are using other packages than OpenCV (such as PyQt) to create GUI.

Option 3 - Headless main module package: pip install opencv-python-headless
Option 4 - Headless full package (contains main module and contrib/extra modules): pip install opencv-contrib-python-headless(check the list of contrib/extra modules in the OpenCV documentation)


Summarize

This article introduces how to install opencv-python with pip.

Guess you like

Origin blog.csdn.net/szylight2022/article/details/127903947