In this tutorial, I will show you how to install Python OpenCV. Before starting Opencv installation, let’s look at what “computer vision” is.

Computer Vision

Computer vision is a field that helps computers understand the real world. There are lots of open-source libraries you can use. Opencv is most used the library in this area. Also, It is an open-source computer vision library. It has more than 2500 optimized algorithms, that include computer vision and machine learning algorithms. OpenCV runs the computer vision algorithms in real-time. It contains many computer vision algorithms. It helps us to apply these algorithms easily and effectively. Some of these algorithms;

  • Object Detection
  • Object Tracking
  • Line Detection
  • Extract 3D models of objects
  • Camera calibration
  • Face Detection

Additionaly, You can run opencv on mac, windows and linux platforms. Also, you can write opencv codes in C,C++,Python and Java programmming languages.

What can you do with OpenCV?

You can do almost any computer vision task you can think of using OpenCV. You have to use many computer vision algorithms and modules together to make computer vision tasks. So you just need to understand which OpenCV modules and functions you need to use to get what you want.

OpenCV provides many built-in functions for image processing and computer vision. If you need to write something from scratch, You need to define Image, Points, and so on. These are essential for almost any computer vision algorithm. When you install the OpenCV library it comes with the basic these structures, algorithms, and modules.

If you want to create these structures from scratch, you need to optimize for speed all of them. But, OpenCV has already all of these optimizations. When you want to read or write the images in OpenCV, you can use OpenCV “imcodecs” module.

Windows

Opencv Install Using PIP

If you have an older version of python than 3.4, you need to install pip. Python 3.4 and later versions come with pip installed.

PIP Installing
python -m pip install -U pip
install opencv using pip
Opencv Install

Open your command line and run the following code.

pip install python_contrib_opencv
install opencv using pip

Install Opencv Using Anaconda

Anaconda is one of the best choices for OpenCV. Because when you install the anaconda, it comes with python libraries and it has an environment to install any python libraries install easily. In this tutorial, I will use this environment. Let’s see how to install OpenCV with anaconda environment.


Step 1: Open your search bar and search the anaconda navigator.

install anaconda opencv

Step 2:

  1. Click the environments section.
  2. Select base(root)
  3. Choose All
  4. Type opencv
  5. Select opencv
  6. Apply and install
install anaconda opencv

If you can’t install the OpenCV with this method, you can use Anaconda prompt.

install anaconda opencv

When you click the Open Terminal section, you will see the following image.

install anaconda opencv

Install Opencv Using Pycharm


If you use pytcharm ide for python you can install opencv easly. But, if you not install pycharm ide download pycharm and install. After the install pycharm ide open it.

install pycharm opencv
install pycharm opencv
install pycharm opencv

Linux


Install opencv using Pip3


In this installation i will use Ubuntu Operating System. Python comes installed on Ubuntu. But, wee need to update python version on ubuntu.


Step-1: Install ppa

This PPA includes the latest versions of Python for Ubuntu. Install ppa by running the following command.

sudo add-apt-repository ppa:deadsnakes/ppa
Step-2 : Update packages

Update all packages by running the following code.

sudo apt-get update
Step-3: Upgrade python 2.x to python 3.x

We need to install python 3.6 version, before 3.8. Run the folllowing command.

sudo apt-get install python3.6
sudo apt-get install python3.8
Step-4 : PiP installation

Install pip by running the following command.

sudo apt install python3-pip
pip3 install --upgrade pip
Step-5 : Install opencv-python

Installing opencv-python by running the following command.

pip install opencv-python

 you want to install OpenCV using Anaconda or Pycharm in ubuntu, you can follow steps on Windows installation. Congratulations you installed OpenCV. In the next tutorial, we will learn how to read, write, and show images.