Translate

How to Install OpenCV for Python on Windows and Ubuntu?

 

How to Install OpenCV for Python on Windows and Ubuntu?

  • Difficulty Level : Easy
  • Last Updated : 05 Oct, 2021
  • Reference : Geeks for geek and Open-CV documentaions

Prerequisite: Python Language Introduction
 
OpenCV is the huge open-source library for computer vision, machine learning, and image processing and now it plays a major role in real-time operation which is very important in today’s systems. By using it, one can process images and videos to identify objects, faces, or even the handwriting of a human. When it integrated with various libraries, such as Numpuy, python is capable of processing the OpenCV array structure for analysis. To Identify image patterns and its various features we use vector space and perform mathematical operations on these features.


 

To install OpenCV, one must have Python and PIP, preinstalled on their system. To check if your system already contains Python, go through the following instructions:

Open the Command line(search for cmd in the Run dialog( + R).
Now run the following command:

python --version

If Python is already installed, it will generate a message with the Python version available.
python-version-check-windows

If Python is not present, go through How to install Python on Windows? and follow the instructions provided.
 
PIP is a package management system used to install and manage software packages/libraries written in Python. These files are stored in a large “on-line repository” termed as Python Package Index (PyPI).
To check if PIP is already installed on your system, just go to the command line and execute the following command:

pip -V

Verification of pip

If PIP is not present, go through How to install PIP on Windows? and follow the instructions provided.

Downloading and Installing OpenCV:

OpenCV can be directly downloaded and installed with the use of pip (package manager). To install OpenCV, just go to the command-line and type the following command:

```

pip install opencv-python

or

pip install opencv-contrib-python

For colab installation command is !pip install opencv-contrib-python
```

Beginning with the installation:

  • Type the command in the Terminal and proceed:
    Getting-Started
  • Collecting Information and downloading data:
    Downloading-Data-for-OpenCV
  • Installing Packages:
    Installing-Packages-OpenCV
  • Finished Installation:
    Finishing-Installation-OpenCV

To check if OpenCV is correctly installed, just run the following commands to perform a version check:

python
>>>import cv2
>>>print(cv2.__version__)

OpenCV-Verification


How to Install OpenCV for Python in Linux?

  • Last Updated : 06 Oct, 2021

Prerequisite: Python Language Introduction
 
OpenCV is the huge open-source library for computer vision, machine learning, and image processing and now it plays a major role in real-time operation which is very important in today’s systems. By using it, one can process images and videos to identify objects, faces, or even the handwriting of a human. When it integrated with various libraries, such as Numpuy, python is capable of processing the OpenCV array structure for analysis. To Identify image patterns and its various features we use vector space and perform mathematical operations on these features.

To install OpenCV, one must have Python and PIP, preinstalled on their system. To check if your system already contains Python, go through the following instructions:

Open the terminal using Ctrl+Alt+T

Now run the following command:
For Python2

python --version

For Python3.x

python3.x --version

If Python is already installed, it will generate a message with the Python version available.

Check-python-version-for-linux

If Python is not present, go through How to install Python on Linux? and follow the instructions provided.
 
PIP is a package management system used to install and manage software packages/libraries written in Python. These files are stored in a large “on-line repository” termed as Python Package Index (PyPI).
To check if PIP is already installed on your system, just go to the terminal and execute the following command:

pip3 --version

pip-Version-check-linux

If PIP is not present, go through How to install PIP on Linux? and follow the instructions provided.

Downloading and Installing OpenCV:

OpenCV can be directly downloaded and installed with the use of pip (package manager). To install OpenCV, just go to the terminal and type the following command:

pip3 install opencv-python

Beginning with the installation:

  • Type the command in the Terminal and proceed:
    OpenCV-Installation-Linux-01
  • Collecting Information and downloading data:
    OpenCV-Installation-Linux-02
  • Installing Packages:
    OpenCV-Installation-Linux-03
  • Finished Installation:
    OpenCV-Installation-Linux-04

To check if OpenCV is correctly installed, just run the following commands to perform a version check:

python3
>>>import cv2
>>>print(cv2.__version__)

OpenCV-Verification-Linux


Comments

Popular Posts

bot

Popular post