Getting Started with Computer Vision with Machine Learning

Sam Ansari
3 min readJan 2, 2021

This short article is an attempt to provide with a concise information on different tools and libraries you would need to get started with developing computer vision system or applications. This is not an exhaustive list of all libraries available in the market. The exact toolset will depend on your particular use case and system requirements. The following information is meant for OpenCV and TensorFlow with Python. The installation instructions are mainly for Linux/Mac OS. Except where PIP is not used, all installation commands for Windows are the same.

If you are looking for details and wish to learn advanced level of computer vision programming (starting from scratch), you may read my book, “Building Computer Vision Applications Using Artificial Neural Networks”, that provides with step-by-step examples in OpenCV and TensorFlow with python. Here is the link to my book


Here is a list of items, and how to install in your dev environment, that you will need to get started with cv.

First, you will need Python version 3.6+. If you already have Python in your dev environment, you can skip the Python installation. Here is the command to install Python on Linux and Mac.

Checking for Installed Python and PIP Version

$ python3 — version

The output of this command should be something like this Python 3.6.5.

$ pip3 — version

This command should show the version number of pip3. For example, pip 19.1

Installing Python and PIP on Ubuntu

Run the following commands in your Ubuntu terminal.

sudo apt update

sudo apt-get install python3-dev python3-pip

Installing Python and PIP on Mac OS

brew update

brew install python

This will install both python and pip.

Installing Python and PIP on CentOS 7

sudo yum install rh-python36

sudo yum groupinstall ‘Development Tools’

You should install and create a virtual environment for all dependencies you will need for CV development. Here is the instructions to setup your virtual environment.

Installing virtualenv

$ sudo pip3 install -U virtualenv

Setup and activate virtualenv

$ mkdir cv (the directory name could be anything you wish)

Then create the virtualenv in this directory, cv

$ virtualenv — system-site-packages -p python3 ./cv

$ source ./cv/bin/activate # for sh, bash, ksh, or zsh

When virtualenv is active, your shell prompt is prefixed with (cv). For example,

(cv) Shamshads-MacBook-Air:~ sansari$

Make sure to do the remainder of the installations from the virtualenv.

Installing and Test TensorFlow

(cv) $ pip install tensorflow

If you need a particular version of Tensorflow, for example, version 1.15, do the following:

(cv) $ pip install tensorflow==1.15

For installing GPU version of tensorflow,

(cv) $ pip install tensorflow-gpu

Test the tensorflow installation by executing the command:

(cv) $ python -c “import tensorflow as tf”

If tensorflow is successfully installed, the above program should not show any error.

Installing OpenCV

$ pip install opencv-contrib-python

If you have Python 3.8, you will need to install OpenCV using the following command.

$ pip install opencv-python

Installing SciPy

$ pip install scipy

Installing Scikit-image

$ pip install scikit-image

Installing matplotlib

$ pip install matplotlib

If you are interested in working through the code examples described in my book, you can checkout the entire source code from the github repository. Here is how you can grab a copy of the source code.

Make sure you have the git client installed in your computer. If not download the git client from

Open the terminal window and execute the command:

$ git clone — depth 1

Notice the depth 1 in the above command. This will get you the latest code and avoid downloading all historical commits, which is of the order of 1.5GB.

Hope this brief tutorial helps you get started with programming in OpenCV and Tensorflow with Python.



Sam Ansari

CEO, author, inventor and thought leader in computer vision, machine learning, and AI. 4 US Patents.