OpenCV Tutorial Introduction


Welcome to this tutorial about OpenCV in python !

The reasons why I have written this article is to fulfil the lack of tutorial about OpenCV in python. Almost all the examples and tutorials about opencv that we can found on the web are realized in C++ which is great but bad for python users in addition to the fact that OpenCV is for more simpler in python than in C++ (my point of view).

This tutorial is articulated around commented samples that shows some OpenCV functionalities with explanations for each of them. The three main parts for this tutorial are:

    • Image Processing: Shows all the operations that we can do on images
    • Video Processing: Basically shows what we can do for images but applied on video which implies speed matters.
    • Working Examples: This parts groups a set of explained scripts that have specifics and useful purposes.

Sources are available on Github



Image Processing

Chapter 1: Let’s start with OpenCV

Chapter 2: Filters and arithmetic

Chapter 3: Pixel Access and Matrix Iteration

Chapter 4: Histogram and Backprojection

Chapter 5: Line, Edge and contours detection

Chapter 6: Object detection

Video Processing

Chapter 7: Video I/O and sources

Chapter 8: Operations on videos

Chapter 9: Tracking moving object

Chapter 10: Movement detection with background

Official OpenCV python Samples

My working scripts


Motion detection

Steganography using LSB method (Github)

Cracking basic captchas


 To write this tutorial I helped myself of two and only books about OpenCV which are both really interesting even though all the examples are in C++.


The most important thing to develop in OpenCV with python is the official documentation that will help you understand every functions how they work theirs parameters..

It is provided on the willowgarage website here.


For Windows binaries are available on Sourceforge.
For Linux its recommended to use binaries provided by the various package manager. Compiling it by hand can be tricky to get all features working.

Starting with OpenCV >>