The OpenCV Tutorials
Release 2.3
July 02, 2011
CONTENTS
1 Introduction to OpenCV 3
1.1 Installation in Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 Using OpenCV with gcc and CMake . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.3 Using OpenCV with Eclipse (plugin CDT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.4 Installation in Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
1.5 Display an Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
1.6 Load and Save an Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2 core module. The Core Functionality 29
2.1 Adding (blending) two images using OpenCV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.2 Changing the contrast and brightness of an image! . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.3 Basic Drawing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
2.4 Fancy Drawing! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
3 imgproc module. Image Processing 51
3.1 Smoothing Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
3.2 Eroding and Dilating . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
3.3 More Morphology Transformations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
3.4 Image Pyramids . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
3.5 Basic Thresholding Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
4 highgui module. High Level GUI and Media 89
4.1 Adding a Trackbar to our applications! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
5 calib3d module. Camera calibration and 3D reconstruction 95
6 feature2d module. 2D Features framework 97
7 video module. Video analysis 99
8 objdetect module. Object Detection 101
9 ml module. Machine Learning 103
10 gpu module. GPU-Accelerated Computer Vision 105
11 General tutorials 107
i
ii
The OpenCV Tutorials, Release 2.3
The following links describe a set of basic OpenCV tutorials. All the source code mentioned here is provide as part
of the OpenCV regular releases, so check before you start copy & pasting the code. The list of tutorials below is
automatically generated from reST files located in our SVN repository.
As always, we would be happy to hear your comments and receive your contributions on any tutorial.
CONTENTS 1