How to Installation OpenCV - learnit

Home Top Ad

Post Top Ad

Saturday, January 15, 2022

How to Installation OpenCV

How to Installation OpenCV

Installation and Usage


1.If you have previous/other manually installed (= not installed via pip) version of OpenCV installed (e.g. cv2 module in the root of Python's site-packages), remove it before installation to avoid conflicts.

2. Make sure that your pip version is up-to-date (19.3 is the minimum supported version): pip install --upgrade pip. Check version with pip -V. For example Linux distributions ship usually with very old pip versions which cause a lot of unexpected problems especially with the manylinux format.

3. Select the correct package for your environment
There are four different packages to choose from (see options 1, 2, 3, and 4 below), and you should ONLY CHOOSE ONE OF THEM. Installing multiple packages in the same environment is not recommended. There is no plugin architecture because all packages share the same namespace (cv2). If you installed multiple packages in the same environment, use pip uninstall to remove them all and reinstall only one.

    a. Desktop environment packages (Windows, macOS, and nearly every GNU/Linux distribution)

        Option 1 - Main modules package: pip install opencv-python

        Option 2 - Full package (contains both main modules and contrib/extra modules): pip install opencv-contrib-python


    b. Packages for server (headless) environments (such as Docker, cloud environments, and so on), with no reliance on GUI libraries.

    These packages are smaller than the previous two because they do not include any GUI functionality (they were not compiled with Qt or other GUI components). This means that the packages avoid a heavy dependency chain to X11 libraries, resulting in smaller Docker images, for example. If you do not use cv2.imshow et al. or if you are using a different package (such as PyQt) than OpenCV to create your GUI, you should always use these packages.


        Option 3-Headless main modules package: pip install opencv-python-headless


        Option 4-Headless full package (contains both main modules and contrib/extra modules): pip install opencv-contrib-python-headless


4.Import the package: import cv2


Please Watching My Video is Below

No comments:

Post a Comment

Post Top Ad