Getting Started with OpenCV

Tharuja Sandeepanie
3 min readMay 11, 2020

--

How to setup the working environment

OpenCV is a library of programming functions mainly aimed at real-time computer vision. It is a library used for Image Processing and mainly used to do all the operations related to Images.

OpenCv can be used to :
1. Read and Write Images.

2. Detection of faces and its features.

3. Detection of shapes like Circle,rectangle etc in a image.

4. Drawing objects and adding texts

5. Text recognition in images. e.g Reading Number Plates.

6. Modifying image quality and colors.

7. Developing Augmented reality apps.

From this article, I’m going to explain how to setup the environment to work with OpenCV .

Install OpenCV on Windows using Anaconda Navigator

Here, I’m going to work with Jupyter Notebook using Anaconda Navigator.So that, first you have to download it via this link and install it into your machine. Make sure to select Add Anaconda to my PATH environment variable when installing.

After installing it open Anaconda Navigator and you can see the below view.

Then give launch in Jupyter Notebook. So, you can see that it will run on a localhost on your default web browser. If you want to open it in your project location, go to Anaconda prompt and change the directory to your project location. Then give Jupyter notebook as the command. So, it will launch Jupyter in your given file location on the local host.

Now inside your project location you have to create a new notebook. For that, select new -— > Python 3 Notebook. Note that, in your notebook dashboard (in the web browser) you can run codes separately in empty boxes.

Then after, we need to import some packages that might need for this.

NumPy - a Python package used for numerical computation.

Matplotlib -a Python package used to build 2D static plots.

These are preinstalled with Anaconda but in order to make sure if those packages are installed well, type the following into one of the cells and do run.

If any error occurred, you need to install the packages by giving the below commands in Anaconda Prompt.

  • To install OpenCv ,
pip install opencv-python
  • To install numpy,
pip install numpy     OR
conda install numpy
  • To install matplotlib,
pip install matplotlib    OR 
conda install matplotlib

OK. Now everything is alright and you can start your coding... From my next article, I will explain some basic operations we can do using OpenCv on images. (link)

--

--