SlideShare a Scribd company logo
2
Most read
3
Most read
4
Most read
Computer Vision
         OpenCV
                       Luigi De Russis
                  Politecnico di Torino
Dipartimento di Automatica e Informatica (DAUIN)
                                    Torino - Italy
                          luigi.derussis@polito.it

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/
What is OpenCV?
    Open source Computer Vision library
            http://opencv.org/
    Originally developed by Intel
    Has more than 2500 optimized algorithms
    C/C++/Python API
            it is written natively in C++
    Cross-platform
                                                                               includes a
            also available for Android and iOS
                                                                                Java API
    Released under a BSD license (it’s free)
    Current release version: 2.4.3RC (October 2012)
10/26/2012                        Luigi De Russis - Computer Vision - OpenCV            2
Various applications…
    Human-Computer Interaction (HCI)
    Object Identification
    Object Recognition
    Face Recognition
    Gesture Recognition
    Motion Tracking
    Image Processing
    Mobile Robotics
    … and so on.

10/26/2012          Luigi De Russis - Computer Vision - OpenCV   3
Why OpenCV? (I)
    Best competitor here: Matlab
    Pros
            Specific
                OpenCV was made for image processing
                Matlab is quite generic
            Speed
                around 30 frames processed per seconds in real time image
                 processing (OpenCV)
                around 4-5 frames processed per seconds in real time image
                 processing (Matlab)
            Efficient
                Matlab needs more system resources than OpenCV
10/26/2012                      Luigi De Russis - Computer Vision - OpenCV    4
Why OpenCV? (II)
    Cons
            Easy of use
            Integrated Development Environment
                you can use Eclipse, Netbeans, Visual Studio, Qt, XCode, … a
                 simple text editor for OpenCV
            Memory management
    Two more “pros”…
            Price (!)
            OpenCV Wrappers
                SimpleCV, JavaCV, Emgu CV, JavacvPro, …



10/26/2012                      Luigi De Russis - Computer Vision - OpenCV      5
Modules (I)
    OpenCV has a modular structure, i.e., the package
     includes several shared or static libraries:
            core
                basic structures and algorithms
            imgproc
                Image Processing algorithms (such as image filtering,
                 geometrical image transformations, histograms, etc.)
            video
                video analysis (such as motion estimation and object tracking)
            highgui
                built-in simple UI
                in addition, we will use Qt
10/26/2012                        Luigi De Russis - Computer Vision - OpenCV      6
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, …)
            ml
                 machine learning classes used for statistical classification,
                  regression and clustering of data
            gpu
                 GPU-accelerated algorithms
10/26/2012                         Luigi De Russis - Computer Vision - OpenCV      7
Data structures (I)
    We speak about C++ API
    All the OpenCV classes and functions are placed
     into the cv namespace
    Mat
            the primary image structure in OpenCV 2.x
            overcomes the “old” IplImage/CvMat problems
             (OpenCV 1.x/C API)
            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
10/26/2012                       Luigi De Russis - Computer Vision - OpenCV   8
Data structures (II)
    Point_ (Point2f, Point, Point2d)
            2D point
            defined by x, y coordinates
                Point first(2, 3);
    Size_ (Size, Size2f)
            2D size structure
            specify the size (width and height) of an image or
             rectangle
    Rect
            2D rectangle object

10/26/2012                   Luigi De Russis - Computer Vision - OpenCV   9
Image I/O
    Image I/O
            imread
                legge un’immagine da file e lo salva in un oggetto di tipo Mat
                 Mat imread(const string& filename, int flags=1)
            imwrite
                salva un’immagine su file
                 bool imwrite(const string& filename, InputArray img,
                 const vector<int>& params=vector<int>())
            imshow
                mostra un’immagine a schermo (in una finestra creata
                 precedentemente)
                 void imshow(const string& winname, InputArray mat)


10/26/2012                       Luigi De Russis - Computer Vision - OpenCV       10
Drawing operations
    Base drawing operations
            circle
                draws a simple or filled circle with a given center and radius on a
                 given image
            line
                draws a line between two point in the given image
            ellipse
                draws an ellipse outline, a filled ellipse, an elliptic arc, a filled
                 ellipse sector, …
            rectangle
                draws a rectangle outline or a filled rectangle
                note that negative thickness will fill the rectangle
10/26/2012                         Luigi De Russis - Computer Vision - OpenCV            11
Color spaces
    Converting color spaces
            cvtColor
                converts an input image from one color space to another
                examples:
                    cvtColor(src, dest, CV_RGB2GRAY);
                    cvtColor(src, dest, CV_HSV2BGR);
                    cvtColor(src, dest, CV_RGB2BGR);
            important, since images in OpenCV uses BGR instead of
             RGB




10/26/2012                       Luigi De Russis - Computer Vision - OpenCV   12
How we can use OpenCV?
    LABINF:
       already installed under Windows
      version 2.3.1

      Qt Creator (4.7.4) is the IDE to be used

    At home:
            feel free to install OpenCV version 2.4.3
                it should be more “stable”
            you can use whatever IDE you like
                but we give full support only for Qt Creator
    Installation:
            see the next set of slides for a step-by-step guide


10/26/2012                           Luigi De Russis - Computer Vision - OpenCV   13
What if I got problems?
    Small problems
            drop me a line                          Problems with Qt and a gray scale image

                luigi.derussis@polito.it
                                                     Awesome student to me

    Normal problems                                  Hi,
                                                      […] I’m using “cvtColor(image, gray, CV_BGR2GRAY);” and Indexed8 to convert an image in
                                                      gray scale but the image is not shown in Qt…

            come to office hours                     Can you help me?

                                                      Regards,
                                                      …
                every Tuesday, 9:00 - 11:00
                LAB6, second floor of DAUIN
                please send an e-mail beforehand
    Enormous problems
            come to the dedicated lessons
                Tuesday 30th October, 9:30-12:30, DAUIN
                Thursday 8th November, 15:00-18:00, DAUIN
10/26/2012                        Luigi De Russis - Computer Vision - OpenCV                                                                    14
What if I got problems?
                                                 OpenCV installation


    Small problems                              Not-So-Awesome student to me

            drop me a line                       Hi,
                                                  […] I followed the guide for installing OpenCV on my Mac but I have an error after step 3. Can
                                                  we meet on next Tuesday to solve the problem?
                luigi.derussis@polito.it         Thanks!

                                                  Regards,

    Normal problems                              …




            come to office hours
                every Tuesday, 9:00 - 11:00
                LAB6, second floor of DAUIN
                please send an e-mail beforehand
    Enormous problems
            come to the dedicated lessons
                Tuesday 30th October, 9:30-12:30, DAUIN
                Thursday 8th November, 15:00-18:00, DAUIN
10/26/2012                        Luigi De Russis - Computer Vision - OpenCV                                                                       15
What if I got problems?
    Small problems
            drop me a line
                luigi.derussis@polito.it
    Normal problems                             Help with OpenCV



            come to office hours                Good student to me

                                                  Hi,
                every Tuesday, 9:00 - 11:00      […] I see the solution of Exercise 2.1 but I don’t understand the following expressions:
                                                  -   main();
                                                  -   int* number;
                LAB6, second floor of DAUIN      -   &timer.
                                                  Can you explain to me what they are?


                please send an e-mail beforehand Regards,
                                                  …




    Enormous problems
            come to the dedicated lessons
                Tuesday 30th October, 9:30-12:30, DAUIN
                Thursday 8th November, 15:00-18:00, DAUIN
10/26/2012                        Luigi De Russis - Computer Vision - OpenCV                                                                 16
An mail not to be sent!!!




10/26/2012   Luigi De Russis - Computer Vision - OpenCV   17
Resources
   OpenCV Wiki
        http://code.opencv.org/projects/opencv/wiki
   OpenCV 2.x Official Documentation
        http://docs.opencv.org/
   User Q&A forum
        http://answers.opencv.org/questions/
   OpenCV 2.x Tutorials
        http://docs.opencv.org/opencv_tutorials.pdf


   Books:
        Robert Laganière, OpenCV 2 Computer Vision Application Programming
         Cookbook, Packt Publishing, ISBN 978-1849513241
        Gary Bradsky, Adrian Kaehler, Learning OpenCV: Computer Vision in C++ with
         the OpenCV Library, O'Reilly Media, ISBN 978-1449314651 (to be published)


10/26/2012                         Luigi De Russis - Computer Vision - OpenCV         18
License
  This work is licensed under the Creative Commons
  “Attribution-NonCommercial-ShareAlike Unported (CC BY-
  NC-SA 3,0)” License.
  You are free:
            to Share - to copy, distribute and transmit the work
            to Remix - to adapt the work
  Under the following conditions:
            Attribution - You must attribute the work in the manner
             specified by the author or licensor (but not in any way that
             suggests that they endorse you or your use of the work).
            Noncommercial - You may not use this work for commercial
             purposes.
            Share Alike - If you alter, transform, or build upon this work,
             you may distribute the resulting work only under the same or
             similar license to this one.

26/10/2012                    Luigi De Russis - Computer Vision - OpenCV       19

More Related Content

What's hot (20)

PDF
OpenCV Introduction
Zachary Blair
 
PDF
Object tracking presentation
MrsShwetaBanait1
 
PPTX
Object detection presentation
AshwinBicholiya
 
PPTX
Introduction to OpenCV
Amit Mandelbaum
 
PPTX
Water jug problem ai part 6
Kirti Verma
 
PDF
Digital image processing using matlab
Amr Rashed
 
PPTX
Developing R Graphical User Interfaces
Setia Pramana
 
PPTX
Object Detection & Tracking
Akshay Gujarathi
 
PDF
digital image processing, image processing
Kalyan Acharjya
 
PDF
Emotion detection using cnn.pptx
RADO7900
 
PPTX
Naive bayes
Ashraf Uddin
 
PDF
Semantic Segmentation - Fully Convolutional Networks for Semantic Segmentation
岳華 杜
 
ODP
Machine Learning with Decision trees
Knoldus Inc.
 
PPTX
Computer Vision
ArtiKhanchandani
 
PPSX
Edge Detection and Segmentation
Dr. A. B. Shinde
 
PDF
Computer vision
Dmitry Ryabokon
 
PPTX
Image classification with Deep Neural Networks
Yogendra Tamang
 
PPTX
Convolutional Neural Network and Its Applications
Kasun Chinthaka Piyarathna
 
PPTX
IMAGE SEGMENTATION.
Tawose Olamide Timothy
 
PPTX
And or graph
Ali A Jalil
 
OpenCV Introduction
Zachary Blair
 
Object tracking presentation
MrsShwetaBanait1
 
Object detection presentation
AshwinBicholiya
 
Introduction to OpenCV
Amit Mandelbaum
 
Water jug problem ai part 6
Kirti Verma
 
Digital image processing using matlab
Amr Rashed
 
Developing R Graphical User Interfaces
Setia Pramana
 
Object Detection & Tracking
Akshay Gujarathi
 
digital image processing, image processing
Kalyan Acharjya
 
Emotion detection using cnn.pptx
RADO7900
 
Naive bayes
Ashraf Uddin
 
Semantic Segmentation - Fully Convolutional Networks for Semantic Segmentation
岳華 杜
 
Machine Learning with Decision trees
Knoldus Inc.
 
Computer Vision
ArtiKhanchandani
 
Edge Detection and Segmentation
Dr. A. B. Shinde
 
Computer vision
Dmitry Ryabokon
 
Image classification with Deep Neural Networks
Yogendra Tamang
 
Convolutional Neural Network and Its Applications
Kasun Chinthaka Piyarathna
 
IMAGE SEGMENTATION.
Tawose Olamide Timothy
 
And or graph
Ali A Jalil
 

Viewers also liked (17)

PDF
OpenCV 3.0 - Latest news and the Roadmap
Eugene Khvedchenya
 
PDF
"The OpenCV Open Source Computer Vision Library: What’s New and What’s Coming...
Edge AI and Vision Alliance
 
PDF
Installing OpenCV 2.4.x with Qt
Luigi De Russis
 
PDF
Looking into the past - feature extraction from historic maps using Python, O...
James Crone
 
PDF
Introduction to OpenCV with python (at taichung.py)
Max Lai
 
PPTX
How to Build & Use OpenCL on OpenCV & Android NDK
Industrial Technology Research Institute (ITRI)(工業技術研究院, 工研院)
 
PDF
Using openCV 3.1.0 with vs2015
Wei-Wen Hsu
 
PDF
Using openCV 2.0 with Dev C++
Wei-Wen Hsu
 
PPTX
Guide: How to Build OpenCV 3.0.0
André Moreira
 
PDF
Introduction to OpenCV (with Java)
Luigi De Russis
 
PDF
Face Recognition with OpenCV and scikit-learn
Shiqiao Du
 
PDF
OpenCV Workshop
Lentin Joseph
 
PDF
"The OpenCV Open Source Computer Vision Library: Latest Developments," a Pres...
Edge AI and Vision Alliance
 
PPTX
Computer Vision, Deep Learning, OpenCV
Farshid Pirahansiah
 
PPT
Automated Face Detection System
Abhiroop Ghatak
 
PPTX
Using openCV 3.2.0 with CodeBlocks
Wei-Wen Hsu
 
PPTX
Install, Compile, Setup, Setting OpenCV 3.2, Visual C++ 2015, Win 64bit,
Farshid Pirahansiah
 
OpenCV 3.0 - Latest news and the Roadmap
Eugene Khvedchenya
 
"The OpenCV Open Source Computer Vision Library: What’s New and What’s Coming...
Edge AI and Vision Alliance
 
Installing OpenCV 2.4.x with Qt
Luigi De Russis
 
Looking into the past - feature extraction from historic maps using Python, O...
James Crone
 
Introduction to OpenCV with python (at taichung.py)
Max Lai
 
Using openCV 3.1.0 with vs2015
Wei-Wen Hsu
 
Using openCV 2.0 with Dev C++
Wei-Wen Hsu
 
Guide: How to Build OpenCV 3.0.0
André Moreira
 
Introduction to OpenCV (with Java)
Luigi De Russis
 
Face Recognition with OpenCV and scikit-learn
Shiqiao Du
 
OpenCV Workshop
Lentin Joseph
 
"The OpenCV Open Source Computer Vision Library: Latest Developments," a Pres...
Edge AI and Vision Alliance
 
Computer Vision, Deep Learning, OpenCV
Farshid Pirahansiah
 
Automated Face Detection System
Abhiroop Ghatak
 
Using openCV 3.2.0 with CodeBlocks
Wei-Wen Hsu
 
Install, Compile, Setup, Setting OpenCV 3.2, Visual C++ 2015, Win 64bit,
Farshid Pirahansiah
 
Ad

Similar to Introduction to OpenCV (20)

PDF
Introduction to OpenCV 2.3.1
Luigi De Russis
 
PDF
Introduction to OpenCV 3.x (with Java)
Luigi De Russis
 
PDF
Image Detection and Count Using Open Computer Vision (Opencv)
IJERA Editor
 
PDF
Installing OpenCV 2.3.1 with Qt
Luigi De Russis
 
PDF
OpenCV (Open source computer vision)
Chetan Allapur
 
PPT
Intro_OpenCV.ppt
RithikRaj25
 
PPTX
OpenCV+Android.pptx
Vishwas459764
 
PPTX
Cvpr2010 open source vision software, intro and training part v open cv and r...
zukun
 
PPTX
PYTHON-OPEEEEEEEEEEEEEEN-CV (1) kgjkg.pptx
CharimaineMarquez2
 
PPTX
PYTHON-OOOOOOOOOOPPPPPPEEEEEEEEN-CV.pptx
CharimaineMarquez2
 
DOCX
Open cv
nanocdac
 
PDF
computer_vision_dummies_with_Opencv.pdf
DeepuChaudhary12
 
PDF
Implementation of Computer Vision Applications using OpenCV in C++
IRJET Journal
 
DOCX
16 OpenCV Functions to Start your Computer Vision journey.docx
ssuser90e017
 
PPTX
Getting started with open cv in raspberry pi
Jayaprakash Nagaruru
 
PPTX
Computer vision
Antonio Radesca
 
PPTX
20110220 computer vision_eruhimov_lecture02
Computer Science Club
 
PDF
Computer Vision Workshop
Helen Tabunshchyk
 
PDF
Starting with OpenCV on i.MX 6 Processors
Toradex
 
PDF
Lecture 1 computer vision introduction
cairo university
 
Introduction to OpenCV 2.3.1
Luigi De Russis
 
Introduction to OpenCV 3.x (with Java)
Luigi De Russis
 
Image Detection and Count Using Open Computer Vision (Opencv)
IJERA Editor
 
Installing OpenCV 2.3.1 with Qt
Luigi De Russis
 
OpenCV (Open source computer vision)
Chetan Allapur
 
Intro_OpenCV.ppt
RithikRaj25
 
OpenCV+Android.pptx
Vishwas459764
 
Cvpr2010 open source vision software, intro and training part v open cv and r...
zukun
 
PYTHON-OPEEEEEEEEEEEEEEN-CV (1) kgjkg.pptx
CharimaineMarquez2
 
PYTHON-OOOOOOOOOOPPPPPPEEEEEEEEN-CV.pptx
CharimaineMarquez2
 
Open cv
nanocdac
 
computer_vision_dummies_with_Opencv.pdf
DeepuChaudhary12
 
Implementation of Computer Vision Applications using OpenCV in C++
IRJET Journal
 
16 OpenCV Functions to Start your Computer Vision journey.docx
ssuser90e017
 
Getting started with open cv in raspberry pi
Jayaprakash Nagaruru
 
Computer vision
Antonio Radesca
 
20110220 computer vision_eruhimov_lecture02
Computer Science Club
 
Computer Vision Workshop
Helen Tabunshchyk
 
Starting with OpenCV on i.MX 6 Processors
Toradex
 
Lecture 1 computer vision introduction
cairo university
 
Ad

More from Luigi De Russis (20)

PDF
Assessing Virtual Assistant Capabilities with Italian Dysarthric Speech
Luigi De Russis
 
PDF
Semantic Web: an Introduction
Luigi De Russis
 
PDF
Programming the Semantic Web
Luigi De Russis
 
PDF
Semantic Web - Ontology 101
Luigi De Russis
 
PDF
AmI 2017 - Python intermediate
Luigi De Russis
 
PDF
AmI 2017 - Python basics
Luigi De Russis
 
PDF
AngularJS: an introduction
Luigi De Russis
 
PDF
AmI 2016 - Python basics
Luigi De Russis
 
PDF
Ambient Intelligence: An Overview
Luigi De Russis
 
PDF
Version Control with Git
Luigi De Russis
 
PDF
LAM 2015 - Social Networks Technologies
Luigi De Russis
 
PDF
AmI 2015 - Python basics
Luigi De Russis
 
PDF
PowerOnt: an ontology-based approach for power consumption estimation in Smar...
Luigi De Russis
 
PDF
Interacting with Smart Environments - Ph.D. Thesis Presentation
Luigi De Russis
 
PDF
Semantic Web: an introduction
Luigi De Russis
 
PDF
Living in Smart Environments - 3rd year PhD Report
Luigi De Russis
 
PDF
Semantic Web: an introduction
Luigi De Russis
 
PDF
Social Network Technologies
Luigi De Russis
 
PDF
Clean Code
Luigi De Russis
 
PDF
Living in Smart Environments - 2nd year PhD Report
Luigi De Russis
 
Assessing Virtual Assistant Capabilities with Italian Dysarthric Speech
Luigi De Russis
 
Semantic Web: an Introduction
Luigi De Russis
 
Programming the Semantic Web
Luigi De Russis
 
Semantic Web - Ontology 101
Luigi De Russis
 
AmI 2017 - Python intermediate
Luigi De Russis
 
AmI 2017 - Python basics
Luigi De Russis
 
AngularJS: an introduction
Luigi De Russis
 
AmI 2016 - Python basics
Luigi De Russis
 
Ambient Intelligence: An Overview
Luigi De Russis
 
Version Control with Git
Luigi De Russis
 
LAM 2015 - Social Networks Technologies
Luigi De Russis
 
AmI 2015 - Python basics
Luigi De Russis
 
PowerOnt: an ontology-based approach for power consumption estimation in Smar...
Luigi De Russis
 
Interacting with Smart Environments - Ph.D. Thesis Presentation
Luigi De Russis
 
Semantic Web: an introduction
Luigi De Russis
 
Living in Smart Environments - 3rd year PhD Report
Luigi De Russis
 
Semantic Web: an introduction
Luigi De Russis
 
Social Network Technologies
Luigi De Russis
 
Clean Code
Luigi De Russis
 
Living in Smart Environments - 2nd year PhD Report
Luigi De Russis
 

Recently uploaded (20)

PPTX
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PDF
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
PPTX
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PPTX
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PDF
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
PPTX
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PPTX
How to Set Maximum Difference Odoo 18 POS
Celine George
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PDF
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
PPTX
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
PDF
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
PDF
The dynastic history of the Chahmana.pdf
PrachiSontakke5
 
PDF
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PDF
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
PPTX
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
How to Set Maximum Difference Odoo 18 POS
Celine George
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
The dynastic history of the Chahmana.pdf
PrachiSontakke5
 
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 

Introduction to OpenCV

  • 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/
  • 2. What is OpenCV?  Open source Computer Vision library  http://opencv.org/  Originally developed by Intel  Has more than 2500 optimized algorithms  C/C++/Python API  it is written natively in C++  Cross-platform includes a  also available for Android and iOS Java API  Released under a BSD license (it’s free)  Current release version: 2.4.3RC (October 2012) 10/26/2012 Luigi De Russis - Computer Vision - OpenCV 2
  • 3. Various applications…  Human-Computer Interaction (HCI)  Object Identification  Object Recognition  Face Recognition  Gesture Recognition  Motion Tracking  Image Processing  Mobile Robotics  … and so on. 10/26/2012 Luigi De Russis - Computer Vision - OpenCV 3
  • 4. Why OpenCV? (I)  Best competitor here: Matlab  Pros  Specific  OpenCV was made for image processing  Matlab is quite generic  Speed  around 30 frames processed per seconds in real time image processing (OpenCV)  around 4-5 frames processed per seconds in real time image processing (Matlab)  Efficient  Matlab needs more system resources than OpenCV 10/26/2012 Luigi De Russis - Computer Vision - OpenCV 4
  • 5. Why OpenCV? (II)  Cons  Easy of use  Integrated Development Environment  you can use Eclipse, Netbeans, Visual Studio, Qt, XCode, … a simple text editor for OpenCV  Memory management  Two more “pros”…  Price (!)  OpenCV Wrappers  SimpleCV, JavaCV, Emgu CV, JavacvPro, … 10/26/2012 Luigi De Russis - Computer Vision - OpenCV 5
  • 6. Modules (I)  OpenCV has a modular structure, i.e., the package includes several shared or static libraries:  core  basic structures and algorithms  imgproc  Image Processing algorithms (such as image filtering, geometrical image transformations, histograms, etc.)  video  video analysis (such as motion estimation and object tracking)  highgui  built-in simple UI  in addition, we will use Qt 10/26/2012 Luigi De Russis - Computer Vision - OpenCV 6
  • 7. 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, …)  ml  machine learning classes used for statistical classification, regression and clustering of data  gpu  GPU-accelerated algorithms 10/26/2012 Luigi De Russis - Computer Vision - OpenCV 7
  • 8. Data structures (I)  We speak about C++ API  All the OpenCV classes and functions are placed into the cv namespace  Mat  the primary image structure in OpenCV 2.x  overcomes the “old” IplImage/CvMat problems (OpenCV 1.x/C API)  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 10/26/2012 Luigi De Russis - Computer Vision - OpenCV 8
  • 9. Data structures (II)  Point_ (Point2f, Point, Point2d)  2D point  defined by x, y coordinates  Point first(2, 3);  Size_ (Size, Size2f)  2D size structure  specify the size (width and height) of an image or rectangle  Rect  2D rectangle object 10/26/2012 Luigi De Russis - Computer Vision - OpenCV 9
  • 10. Image I/O  Image I/O  imread  legge un’immagine da file e lo salva in un oggetto di tipo Mat Mat imread(const string& filename, int flags=1)  imwrite  salva un’immagine su file bool imwrite(const string& filename, InputArray img, const vector<int>& params=vector<int>())  imshow  mostra un’immagine a schermo (in una finestra creata precedentemente) void imshow(const string& winname, InputArray mat) 10/26/2012 Luigi De Russis - Computer Vision - OpenCV 10
  • 11. Drawing operations  Base drawing operations  circle  draws a simple or filled circle with a given center and radius on a given image  line  draws a line between two point in the given image  ellipse  draws an ellipse outline, a filled ellipse, an elliptic arc, a filled ellipse sector, …  rectangle  draws a rectangle outline or a filled rectangle  note that negative thickness will fill the rectangle 10/26/2012 Luigi De Russis - Computer Vision - OpenCV 11
  • 12. Color spaces  Converting color spaces  cvtColor  converts an input image from one color space to another  examples:  cvtColor(src, dest, CV_RGB2GRAY);  cvtColor(src, dest, CV_HSV2BGR);  cvtColor(src, dest, CV_RGB2BGR);  important, since images in OpenCV uses BGR instead of RGB 10/26/2012 Luigi De Russis - Computer Vision - OpenCV 12
  • 13. How we can use OpenCV?  LABINF:  already installed under Windows  version 2.3.1  Qt Creator (4.7.4) is the IDE to be used  At home:  feel free to install OpenCV version 2.4.3  it should be more “stable”  you can use whatever IDE you like  but we give full support only for Qt Creator  Installation:  see the next set of slides for a step-by-step guide 10/26/2012 Luigi De Russis - Computer Vision - OpenCV 13
  • 14. What if I got problems?  Small problems  drop me a line Problems with Qt and a gray scale image  [email protected] Awesome student to me  Normal problems Hi, […] I’m using “cvtColor(image, gray, CV_BGR2GRAY);” and Indexed8 to convert an image in gray scale but the image is not shown in Qt…  come to office hours Can you help me? Regards, …  every Tuesday, 9:00 - 11:00  LAB6, second floor of DAUIN  please send an e-mail beforehand  Enormous problems  come to the dedicated lessons  Tuesday 30th October, 9:30-12:30, DAUIN  Thursday 8th November, 15:00-18:00, DAUIN 10/26/2012 Luigi De Russis - Computer Vision - OpenCV 14
  • 15. What if I got problems? OpenCV installation  Small problems Not-So-Awesome student to me  drop me a line Hi, […] I followed the guide for installing OpenCV on my Mac but I have an error after step 3. Can we meet on next Tuesday to solve the problem?  [email protected] Thanks! Regards,  Normal problems …  come to office hours  every Tuesday, 9:00 - 11:00  LAB6, second floor of DAUIN  please send an e-mail beforehand  Enormous problems  come to the dedicated lessons  Tuesday 30th October, 9:30-12:30, DAUIN  Thursday 8th November, 15:00-18:00, DAUIN 10/26/2012 Luigi De Russis - Computer Vision - OpenCV 15
  • 16. What if I got problems?  Small problems  drop me a line  [email protected]  Normal problems Help with OpenCV  come to office hours Good student to me Hi,  every Tuesday, 9:00 - 11:00 […] I see the solution of Exercise 2.1 but I don’t understand the following expressions: - main(); - int* number;  LAB6, second floor of DAUIN - &timer. Can you explain to me what they are?  please send an e-mail beforehand Regards, …  Enormous problems  come to the dedicated lessons  Tuesday 30th October, 9:30-12:30, DAUIN  Thursday 8th November, 15:00-18:00, DAUIN 10/26/2012 Luigi De Russis - Computer Vision - OpenCV 16
  • 17. An mail not to be sent!!! 10/26/2012 Luigi De Russis - Computer Vision - OpenCV 17
  • 18. Resources  OpenCV Wiki  http://code.opencv.org/projects/opencv/wiki  OpenCV 2.x Official Documentation  http://docs.opencv.org/  User Q&A forum  http://answers.opencv.org/questions/  OpenCV 2.x Tutorials  http://docs.opencv.org/opencv_tutorials.pdf  Books:  Robert Laganière, OpenCV 2 Computer Vision Application Programming Cookbook, Packt Publishing, ISBN 978-1849513241  Gary Bradsky, Adrian Kaehler, Learning OpenCV: Computer Vision in C++ with the OpenCV Library, O'Reilly Media, ISBN 978-1449314651 (to be published) 10/26/2012 Luigi De Russis - Computer Vision - OpenCV 18
  • 19. License This work is licensed under the Creative Commons “Attribution-NonCommercial-ShareAlike Unported (CC BY- NC-SA 3,0)” License. You are free:  to Share - to copy, distribute and transmit the work  to Remix - to adapt the work Under the following conditions:  Attribution - You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work).  Noncommercial - You may not use this work for commercial purposes.  Share Alike - If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one. 26/10/2012 Luigi De Russis - Computer Vision - OpenCV 19