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
 
PPTX
Introduction to OpenCV
Amit Mandelbaum
 
PPTX
Facial Emotion Recognition: A Deep Learning approach
AshwinRachha
 
PDF
Convolutional Neural Networks (CNN)
Gaurav Mittal
 
PPTX
Image classification with Deep Neural Networks
Yogendra Tamang
 
PPTX
Homomorphic filtering
Gautam Saxena
 
PPTX
Image processing ppt
Raviteja Chowdary Adusumalli
 
PPTX
Convolution Neural Network (CNN)
Suraj Aavula
 
PPTX
Object Detection & Tracking
Akshay Gujarathi
 
PPTX
color detection using open cv
Anil Pokhrel
 
PPT
Image segmentation ppt
Gichelle Amon
 
PDF
Digital Image Processing: Image Segmentation
Mostafa G. M. Mostafa
 
PPTX
Image Classification using deep learning
Asma-AH
 
PPTX
Smoothing in Digital Image Processing
Pallavi Agarwal
 
PPTX
Object detection with deep learning
Sushant Shrivastava
 
PDF
I.INFORMED SEARCH IN ARTIFICIAL INTELLIGENCE II. HEURISTIC FUNCTION IN AI III...
vikas dhakane
 
PPT
Back propagation
Nagarajan
 
PPTX
Computer Vision Introduction
Camera Culture Group, MIT Media Lab
 
PPTX
Object Recognition
Eman Abed AlWahhab
 
PPTX
Image feature extraction
Rushin Shah
 
OpenCV Introduction
Zachary Blair
 
Introduction to OpenCV
Amit Mandelbaum
 
Facial Emotion Recognition: A Deep Learning approach
AshwinRachha
 
Convolutional Neural Networks (CNN)
Gaurav Mittal
 
Image classification with Deep Neural Networks
Yogendra Tamang
 
Homomorphic filtering
Gautam Saxena
 
Image processing ppt
Raviteja Chowdary Adusumalli
 
Convolution Neural Network (CNN)
Suraj Aavula
 
Object Detection & Tracking
Akshay Gujarathi
 
color detection using open cv
Anil Pokhrel
 
Image segmentation ppt
Gichelle Amon
 
Digital Image Processing: Image Segmentation
Mostafa G. M. Mostafa
 
Image Classification using deep learning
Asma-AH
 
Smoothing in Digital Image Processing
Pallavi Agarwal
 
Object detection with deep learning
Sushant Shrivastava
 
I.INFORMED SEARCH IN ARTIFICIAL INTELLIGENCE II. HEURISTIC FUNCTION IN AI III...
vikas dhakane
 
Back propagation
Nagarajan
 
Computer Vision Introduction
Camera Culture Group, MIT Media Lab
 
Object Recognition
Eman Abed AlWahhab
 
Image feature extraction
Rushin Shah
 

Viewers also liked (18)

PDF
OpenCV 3.0 - Latest news and the Roadmap
Eugene Khvedchenya
 
ODP
Image Processing with OpenCV
debayanin
 
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
 
Image Processing with OpenCV
debayanin
 
"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
 
PPTX
OpenCV+Android.pptx
Vishwas459764
 
PDF
Introduction to OpenCV 3.x (with Java)
Luigi De Russis
 
PDF
Image Detection and Count Using Open Computer Vision (Opencv)
IJERA Editor
 
PDF
Automatic License Plate Recognition using OpenCV
Editor IJCATR
 
PDF
Automatic License Plate Recognition using OpenCV
Editor IJCATR
 
PDF
Portfolio
Ivan Khomyakov
 
PDF
Image Processing In Open CV. Image Processing In Open CV. Image Processing In...
Antoinette Williams
 
PPT
Intro_OpenCV.ppt
RithikRaj25
 
PDF
Implementation of embedded arm9 platform using qt and open cv for human upper...
Krunal Patel
 
PDF
On technology transfer: experience from the CARP project... and beyond
dividiti
 
PPTX
BEST IMAGE PROCESSING TOOLS TO EXPECT in 2023 – Tutors India
Tutors India
 
PDF
OpenCV (Open source computer vision)
Chetan Allapur
 
PDF
Corey.Berry.Portfolio.2016
Corey Berry
 
PPT
CS 354 Introduction
Mark Kilgard
 
PDF
Log polar coordinates
Oğul Göçmen
 
PPT
lec1b.ppt
RithikRaj25
 
DOCX
16 OpenCV Functions to Start your Computer Vision journey.docx
ssuser90e017
 
PDF
Hacking the Kinect with GAFFTA Day 1
benDesigning
 
PDF
Finding Resource Manipulation Bugs in Linux Code
Andrzej Wasowski
 
Introduction to OpenCV 2.3.1
Luigi De Russis
 
OpenCV+Android.pptx
Vishwas459764
 
Introduction to OpenCV 3.x (with Java)
Luigi De Russis
 
Image Detection and Count Using Open Computer Vision (Opencv)
IJERA Editor
 
Automatic License Plate Recognition using OpenCV
Editor IJCATR
 
Automatic License Plate Recognition using OpenCV
Editor IJCATR
 
Portfolio
Ivan Khomyakov
 
Image Processing In Open CV. Image Processing In Open CV. Image Processing In...
Antoinette Williams
 
Intro_OpenCV.ppt
RithikRaj25
 
Implementation of embedded arm9 platform using qt and open cv for human upper...
Krunal Patel
 
On technology transfer: experience from the CARP project... and beyond
dividiti
 
BEST IMAGE PROCESSING TOOLS TO EXPECT in 2023 – Tutors India
Tutors India
 
OpenCV (Open source computer vision)
Chetan Allapur
 
Corey.Berry.Portfolio.2016
Corey Berry
 
CS 354 Introduction
Mark Kilgard
 
Log polar coordinates
Oğul Göçmen
 
lec1b.ppt
RithikRaj25
 
16 OpenCV Functions to Start your Computer Vision journey.docx
ssuser90e017
 
Hacking the Kinect with GAFFTA Day 1
benDesigning
 
Finding Resource Manipulation Bugs in Linux Code
Andrzej Wasowski
 
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
ENGLISH 8 REVISED K-12 CURRICULUM QUARTER 1 WEEK 1
LeomarrYsraelArzadon
 
PDF
TLE 8 QUARTER 1 MODULE WEEK 1 MATATAG CURRICULUM
denniseraya1997
 
PDF
AI-assisted IP-Design lecture from the MIPLM 2025
MIPLM
 
PPTX
Iván Bornacelly - Presentation of the report - Empowering the workforce in th...
EduSkills OECD
 
PPTX
How to Configure Taxes in Company Currency in Odoo 18 Accounting
Celine George
 
PDF
Andreas Schleicher_Teaching Compass_Education 2040.pdf
EduSkills OECD
 
PPTX
Lesson 1 Cell (Structures, Functions, and Theory).pptx
marvinnbustamante1
 
PPTX
Marketing Management PPT Unit 1 and Unit 2.pptx
Sri Ramakrishna College of Arts and science
 
PDF
Supply Chain Security A Comprehensive Approach 1st Edition Arthur G. Arway
rxgnika452
 
PPTX
Building Powerful Agentic AI with Google ADK, MCP, RAG, and Ollama.pptx
Tamanna36
 
PPTX
PLANNING FOR EMERGENCY AND DISASTER MANAGEMENT ppt.pptx
PRADEEP ABOTHU
 
PPTX
How to Manage Wins & Losses in Odoo 18 CRM
Celine George
 
PDF
I3PM Industry Case Study Siemens on Strategic and Value-Oriented IP Management
MIPLM
 
PDF
DIGESTION OF CARBOHYDRATES ,PROTEINS AND LIPIDS
raviralanaresh2
 
PPTX
Connecting Linear and Angular Quantities in Human Movement.pptx
AngeliqueTolentinoDe
 
PDF
Our Guide to the July 2025 USPS® Rate Change
Postal Advocate Inc.
 
PPTX
How to Add a Custom Button in Odoo 18 POS Screen
Celine George
 
PPTX
Ward Management: Patient Care, Personnel, Equipment, and Environment.pptx
PRADEEP ABOTHU
 
PPTX
grade 8 week 2 ict.pptx. matatag grade 7
VanessaTaberlo
 
PPTX
How to Create & Manage Stages in Odoo 18 Helpdesk
Celine George
 
ENGLISH 8 REVISED K-12 CURRICULUM QUARTER 1 WEEK 1
LeomarrYsraelArzadon
 
TLE 8 QUARTER 1 MODULE WEEK 1 MATATAG CURRICULUM
denniseraya1997
 
AI-assisted IP-Design lecture from the MIPLM 2025
MIPLM
 
Iván Bornacelly - Presentation of the report - Empowering the workforce in th...
EduSkills OECD
 
How to Configure Taxes in Company Currency in Odoo 18 Accounting
Celine George
 
Andreas Schleicher_Teaching Compass_Education 2040.pdf
EduSkills OECD
 
Lesson 1 Cell (Structures, Functions, and Theory).pptx
marvinnbustamante1
 
Marketing Management PPT Unit 1 and Unit 2.pptx
Sri Ramakrishna College of Arts and science
 
Supply Chain Security A Comprehensive Approach 1st Edition Arthur G. Arway
rxgnika452
 
Building Powerful Agentic AI with Google ADK, MCP, RAG, and Ollama.pptx
Tamanna36
 
PLANNING FOR EMERGENCY AND DISASTER MANAGEMENT ppt.pptx
PRADEEP ABOTHU
 
How to Manage Wins & Losses in Odoo 18 CRM
Celine George
 
I3PM Industry Case Study Siemens on Strategic and Value-Oriented IP Management
MIPLM
 
DIGESTION OF CARBOHYDRATES ,PROTEINS AND LIPIDS
raviralanaresh2
 
Connecting Linear and Angular Quantities in Human Movement.pptx
AngeliqueTolentinoDe
 
Our Guide to the July 2025 USPS® Rate Change
Postal Advocate Inc.
 
How to Add a Custom Button in Odoo 18 POS Screen
Celine George
 
Ward Management: Patient Care, Personnel, Equipment, and Environment.pptx
PRADEEP ABOTHU
 
grade 8 week 2 ict.pptx. matatag grade 7
VanessaTaberlo
 
How to Create & Manage Stages in Odoo 18 Helpdesk
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