introduction to opencv 2.3.1

12
Computer Vision OpenCV Luigi De Russis Politecnico di Torino Dipartimento di Automatica e Informatica (DAUIN) Torino - Italy [email protected] This work is licensed under the Creative Commons (CC BY-SA) License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/

Upload: luigi-de-russis

Post on 26-Jan-2015

160 views

Category:

Education


7 download

DESCRIPTION

A brief introduction to OpenCV 2.3.1 for the Computer Vision Course at Politecnico di Torino (academic year 2011/2012).

TRANSCRIPT

Page 1: Introduction to OpenCV 2.3.1

Computer Vision

OpenCV

Luigi De Russis

Politecnico di Torino Dipartimento di Automatica e Informatica (DAUIN)

Torino - Italy

[email protected]

This work is licensed under the Creative Commons (CC BY-SA)

License. To view a copy of this license, visit

http://creativecommons.org/licenses/by-sa/3.0/

Page 2: Introduction to OpenCV 2.3.1

11/09/2011 Luigi De Russis - Computer Vision - OpenCV 2

What is OpenCV?

Open source Computer Vision library

Cross-platform

C/C++ API

Originally developed by Intel

Optimized and intended for real-time applications

More than 500 functions available

Current release version: 2.3.1 (August 2011)

Website: http://opencv.willowgarage.com/

Page 3: Introduction to OpenCV 2.3.1

11/09/2011 Luigi De Russis - Computer Vision - OpenCV 3

Uses

Human-Computer Interaction (HCI)

Object Identification

Object Recognition

Face Recognition

Gesture Recognition

Motion Tracking

Image Processing

Mobile Robotics

… and so on.

Page 4: Introduction to OpenCV 2.3.1

11/09/2011 Luigi De Russis - Computer Vision - OpenCV 4

OpenCV modules (I)

core

basic structures and algorithms

imgproc

Image Processing algorithms (such as image filtering,

geometrical image transformations, histograms, etc.)

highgui

built-in simple UI

video

video analysis (such as motion estimation and object

tracking)

we will use Qt, in

addition to it

Page 5: Introduction to OpenCV 2.3.1

11/09/2011 Luigi De Russis - Computer Vision - OpenCV 5

OpenCV modules (II)

calib3d

camera calibration and 3D reconstruction

features2d

2D features framework (feature detectors, descriptors,

and descriptor matchers)

objdetect

detection of objects and other items (e.g., faces, eyes,

mugs, people, …)

Page 6: Introduction to OpenCV 2.3.1

11/09/2011 Luigi De Russis - Computer Vision - OpenCV 6

OpenCV modules (III)

ml

machine learning classes used for statistical

classification, regression and clustering of data

gpu

GPU-accelerated algorithms

Page 7: Introduction to OpenCV 2.3.1

11/09/2011

Luigi De Russis - Computer Vision - OpenCV 7

cv::Mat

cv

all the OpenCV classes and functions are placed into the cv namespace

Mat

the basic image structure in OpenCV

overcomes the “old” IplImage problems

automatic memory management (more or less)

two data parts:

matrix header (contains information about the matrix)

a pointer to the matrix containing the pixel values

Page 8: Introduction to OpenCV 2.3.1

11/09/2011 Luigi De Russis - Computer Vision - OpenCV 8

Demo Hour (I): Hello CV

Goal: to load an image and show it

Project available on the course page

Two files:

helloCV.pro

main.cpp

Page 9: Introduction to OpenCV 2.3.1

11/09/2011

Luigi De Russis - Computer Vision - OpenCV 9

Demo Hour (II)

helloCV.pro, the Qt project file (the one to open!)

to modify/copy on each new OpenCV+Qt project

two important variables has to be defined:

INCLUDEPATH += path/to/opencv/include \

LIBS += -Lpath/to/opencv/library \

-lopencv_core231d \

-lopencv_highgui231d \

-lopencv_imgproc231d \

… \

-lopencv_video231d

Page 10: Introduction to OpenCV 2.3.1

11/09/2011

Luigi De Russis - Computer Vision - OpenCV 10

Demo Hour (III)

main.cpp, the code that loads and shows an image

//read an image

cv::Mat image = cv::imread("image.jpg");

//create an image window named "Hello CV“ cv::namedWindow("Hello CV");

//now, show the image on window

cv::imshow("Hello CV", image);

Page 11: Introduction to OpenCV 2.3.1

11/09/2011

Luigi De Russis - Computer Vision - OpenCV 11

Demo Hour (IV)

Now, press “Run”…

Page 12: Introduction to OpenCV 2.3.1

11/09/2011 Luigi De Russis - Computer Vision - OpenCV 12

Resources

OpenCV (Full) Wiki http://opencv.willowgarage.com/wiki/FullOpenCVWiki

OpenCV 2.3 Documentation http://opencv.itseez.com/

[Book] Robert Laganière, OpenCV 2 Computer Vision Application Programming Cookbook, Packt Publishing

OpenCV User Group http://groups.yahoo.com/group/OpenCV/

OpenCV 2.3 Tutorials https://code.ros.org/trac/opencv/export/5642/trunk/opencv/doc/opencv_tutorials.pdf