SlideShare uma empresa Scribd logo
1 de 19
Baixar para ler offline
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

Mais conteúdo relacionado

Mais procurados

Human activity recognition
Human activity recognition Human activity recognition
Human activity recognition
srikanthgadam
 

Mais procurados (20)

Image Processing with OpenCV
Image Processing with OpenCVImage Processing with OpenCV
Image Processing with OpenCV
 
IMAGE SEGMENTATION.
IMAGE SEGMENTATION.IMAGE SEGMENTATION.
IMAGE SEGMENTATION.
 
Computer vision
Computer visionComputer vision
Computer vision
 
Introduction to Computer Vision using OpenCV
Introduction to Computer Vision using OpenCVIntroduction to Computer Vision using OpenCV
Introduction to Computer Vision using OpenCV
 
Edge detection
Edge detectionEdge detection
Edge detection
 
Image analysis using python
Image analysis using pythonImage analysis using python
Image analysis using python
 
Image Segmentation (Digital Image Processing)
Image Segmentation (Digital Image Processing)Image Segmentation (Digital Image Processing)
Image Segmentation (Digital Image Processing)
 
Object Detection & Tracking
Object Detection & TrackingObject Detection & Tracking
Object Detection & Tracking
 
Object detection presentation
Object detection presentationObject detection presentation
Object detection presentation
 
Human activity recognition
Human activity recognition Human activity recognition
Human activity recognition
 
Application of image processing
Application of image processingApplication of image processing
Application of image processing
 
Introduction and Application of Computer Graphics.
Introduction and Application of Computer Graphics.Introduction and Application of Computer Graphics.
Introduction and Application of Computer Graphics.
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
Opencv
OpencvOpencv
Opencv
 
Image Enhancement - Point Processing
Image Enhancement - Point ProcessingImage Enhancement - Point Processing
Image Enhancement - Point Processing
 
Brain tumor detection using image segmentation ppt
Brain tumor detection using image segmentation pptBrain tumor detection using image segmentation ppt
Brain tumor detection using image segmentation ppt
 
Object recognition
Object recognitionObject recognition
Object recognition
 
Noise Models
Noise ModelsNoise Models
Noise Models
 
1.arithmetic & logical operations
1.arithmetic & logical operations1.arithmetic & logical operations
1.arithmetic & logical operations
 
Segmentation
SegmentationSegmentation
Segmentation
 

Destaque

OpenCV 3.0 - Latest news and the Roadmap
OpenCV 3.0 - Latest news and the RoadmapOpenCV 3.0 - Latest news and the Roadmap
OpenCV 3.0 - Latest news and the Roadmap
Eugene Khvedchenya
 
Installing OpenCV 2.4.x with Qt
Installing OpenCV 2.4.x with QtInstalling OpenCV 2.4.x with Qt
Installing OpenCV 2.4.x with Qt
Luigi De Russis
 
"The OpenCV Open Source Computer Vision Library: Latest Developments," a Pres...
"The OpenCV Open Source Computer Vision Library: Latest Developments," a Pres..."The OpenCV Open Source Computer Vision Library: Latest Developments," a Pres...
"The OpenCV Open Source Computer Vision Library: Latest Developments," a Pres...
Edge AI and Vision Alliance
 

Destaque (16)

OpenCV 3.0 - Latest news and the Roadmap
OpenCV 3.0 - Latest news and the RoadmapOpenCV 3.0 - Latest news and the Roadmap
OpenCV 3.0 - Latest news and the Roadmap
 
Installing OpenCV 2.4.x with Qt
Installing OpenCV 2.4.x with QtInstalling OpenCV 2.4.x with Qt
Installing OpenCV 2.4.x with Qt
 
Looking into the past - feature extraction from historic maps using Python, O...
Looking into the past - feature extraction from historic maps using Python, O...Looking into the past - feature extraction from historic maps using Python, O...
Looking into the past - feature extraction from historic maps using Python, O...
 
Introduction to OpenCV with python (at taichung.py)
Introduction to OpenCV with python (at taichung.py)Introduction to OpenCV with python (at taichung.py)
Introduction to OpenCV with python (at taichung.py)
 
How to Build & Use OpenCL on OpenCV & Android NDK
How to Build & Use OpenCL on OpenCV & Android NDKHow to Build & Use OpenCL on OpenCV & Android NDK
How to Build & Use OpenCL on OpenCV & Android NDK
 
Using openCV 3.1.0 with vs2015
Using openCV 3.1.0 with vs2015Using openCV 3.1.0 with vs2015
Using openCV 3.1.0 with vs2015
 
Using openCV 2.0 with Dev C++
Using openCV 2.0 with Dev C++Using openCV 2.0 with Dev C++
Using openCV 2.0 with Dev C++
 
Guide: How to Build OpenCV 3.0.0
Guide: How to Build OpenCV 3.0.0Guide: How to Build OpenCV 3.0.0
Guide: How to Build OpenCV 3.0.0
 
Introduction to OpenCV (with Java)
Introduction to OpenCV (with Java)Introduction to OpenCV (with Java)
Introduction to OpenCV (with Java)
 
Face Recognition with OpenCV and scikit-learn
Face Recognition with OpenCV and scikit-learnFace Recognition with OpenCV and scikit-learn
Face Recognition with OpenCV and scikit-learn
 
OpenCV Workshop
OpenCV WorkshopOpenCV Workshop
OpenCV Workshop
 
"The OpenCV Open Source Computer Vision Library: Latest Developments," a Pres...
"The OpenCV Open Source Computer Vision Library: Latest Developments," a Pres..."The OpenCV Open Source Computer Vision Library: Latest Developments," a Pres...
"The OpenCV Open Source Computer Vision Library: Latest Developments," a Pres...
 
Computer Vision, Deep Learning, OpenCV
Computer Vision, Deep Learning, OpenCVComputer Vision, Deep Learning, OpenCV
Computer Vision, Deep Learning, OpenCV
 
Automated Face Detection System
Automated Face Detection SystemAutomated Face Detection System
Automated Face Detection System
 
Using openCV 3.2.0 with CodeBlocks
Using openCV 3.2.0 with CodeBlocksUsing openCV 3.2.0 with CodeBlocks
Using openCV 3.2.0 with CodeBlocks
 
Install, Compile, Setup, Setting OpenCV 3.2, Visual C++ 2015, Win 64bit,
Install, Compile, Setup, Setting OpenCV 3.2, Visual C++ 2015, Win 64bit, Install, Compile, Setup, Setting OpenCV 3.2, Visual C++ 2015, Win 64bit,
Install, Compile, Setup, Setting OpenCV 3.2, Visual C++ 2015, Win 64bit,
 

Semelhante a Introduction to OpenCV

Implementation of embedded arm9 platform using qt and open cv for human upper...
Implementation of embedded arm9 platform using qt and open cv for human upper...Implementation of embedded arm9 platform using qt and open cv for human upper...
Implementation of embedded arm9 platform using qt and open cv for human upper...
Krunal Patel
 
Corey.Berry.Portfolio.2016
Corey.Berry.Portfolio.2016Corey.Berry.Portfolio.2016
Corey.Berry.Portfolio.2016
Corey Berry
 
16 OpenCV Functions to Start your Computer Vision journey.docx
16 OpenCV Functions to Start your Computer Vision journey.docx16 OpenCV Functions to Start your Computer Vision journey.docx
16 OpenCV Functions to Start your Computer Vision journey.docx
ssuser90e017
 
Finding Resource Manipulation Bugs in Linux Code
Finding Resource Manipulation Bugs in Linux CodeFinding Resource Manipulation Bugs in Linux Code
Finding Resource Manipulation Bugs in Linux Code
Andrzej Wasowski
 

Semelhante a Introduction to OpenCV (20)

Introduction to OpenCV 2.3.1
Introduction to OpenCV 2.3.1Introduction to OpenCV 2.3.1
Introduction to OpenCV 2.3.1
 
OpenCV+Android.pptx
OpenCV+Android.pptxOpenCV+Android.pptx
OpenCV+Android.pptx
 
Introduction to OpenCV 3.x (with Java)
Introduction to OpenCV 3.x (with Java)Introduction to OpenCV 3.x (with Java)
Introduction to OpenCV 3.x (with Java)
 
Image Detection and Count Using Open Computer Vision (Opencv)
Image Detection and Count Using Open Computer Vision (Opencv)Image Detection and Count Using Open Computer Vision (Opencv)
Image Detection and Count Using Open Computer Vision (Opencv)
 
Automatic License Plate Recognition using OpenCV
Automatic License Plate Recognition using OpenCVAutomatic License Plate Recognition using OpenCV
Automatic License Plate Recognition using OpenCV
 
Automatic License Plate Recognition using OpenCV
Automatic License Plate Recognition using OpenCV Automatic License Plate Recognition using OpenCV
Automatic License Plate Recognition using OpenCV
 
Portfolio
PortfolioPortfolio
Portfolio
 
Image Processing In Open CV. Image Processing In Open CV. Image Processing In...
Image Processing In Open CV. Image Processing In Open CV. Image Processing In...Image Processing In Open CV. Image Processing In Open CV. Image Processing In...
Image Processing In Open CV. Image Processing In Open CV. Image Processing In...
 
Intro_OpenCV.ppt
Intro_OpenCV.pptIntro_OpenCV.ppt
Intro_OpenCV.ppt
 
Implementation of embedded arm9 platform using qt and open cv for human upper...
Implementation of embedded arm9 platform using qt and open cv for human upper...Implementation of embedded arm9 platform using qt and open cv for human upper...
Implementation of embedded arm9 platform using qt and open cv for human upper...
 
On technology transfer: experience from the CARP project... and beyond
On technology transfer: experience from the CARP project... and beyondOn technology transfer: experience from the CARP project... and beyond
On technology transfer: experience from the CARP project... and beyond
 
BEST IMAGE PROCESSING TOOLS TO EXPECT in 2023 – Tutors India
BEST IMAGE PROCESSING TOOLS TO EXPECT in 2023 – Tutors IndiaBEST IMAGE PROCESSING TOOLS TO EXPECT in 2023 – Tutors India
BEST IMAGE PROCESSING TOOLS TO EXPECT in 2023 – Tutors India
 
OpenCV (Open source computer vision)
OpenCV (Open source computer vision)OpenCV (Open source computer vision)
OpenCV (Open source computer vision)
 
Corey.Berry.Portfolio.2016
Corey.Berry.Portfolio.2016Corey.Berry.Portfolio.2016
Corey.Berry.Portfolio.2016
 
CS 354 Introduction
CS 354 IntroductionCS 354 Introduction
CS 354 Introduction
 
Log polar coordinates
Log polar coordinatesLog polar coordinates
Log polar coordinates
 
lec1b.ppt
lec1b.pptlec1b.ppt
lec1b.ppt
 
16 OpenCV Functions to Start your Computer Vision journey.docx
16 OpenCV Functions to Start your Computer Vision journey.docx16 OpenCV Functions to Start your Computer Vision journey.docx
16 OpenCV Functions to Start your Computer Vision journey.docx
 
Hacking the Kinect with GAFFTA Day 1
Hacking the Kinect with GAFFTA Day 1Hacking the Kinect with GAFFTA Day 1
Hacking the Kinect with GAFFTA Day 1
 
Finding Resource Manipulation Bugs in Linux Code
Finding Resource Manipulation Bugs in Linux CodeFinding Resource Manipulation Bugs in Linux Code
Finding Resource Manipulation Bugs in Linux Code
 

Mais de Luigi De Russis

Mais de Luigi De Russis (20)

Assessing Virtual Assistant Capabilities with Italian Dysarthric Speech
Assessing Virtual Assistant Capabilities with Italian Dysarthric SpeechAssessing Virtual Assistant Capabilities with Italian Dysarthric Speech
Assessing Virtual Assistant Capabilities with Italian Dysarthric Speech
 
Semantic Web: an Introduction
Semantic Web: an IntroductionSemantic Web: an Introduction
Semantic Web: an Introduction
 
Programming the Semantic Web
Programming the Semantic WebProgramming the Semantic Web
Programming the Semantic Web
 
Semantic Web - Ontology 101
Semantic Web - Ontology 101Semantic Web - Ontology 101
Semantic Web - Ontology 101
 
AmI 2017 - Python intermediate
AmI 2017 - Python intermediateAmI 2017 - Python intermediate
AmI 2017 - Python intermediate
 
AmI 2017 - Python basics
AmI 2017 - Python basicsAmI 2017 - Python basics
AmI 2017 - Python basics
 
AngularJS: an introduction
AngularJS: an introductionAngularJS: an introduction
AngularJS: an introduction
 
AmI 2016 - Python basics
AmI 2016 - Python basicsAmI 2016 - Python basics
AmI 2016 - Python basics
 
Ambient Intelligence: An Overview
Ambient Intelligence: An OverviewAmbient Intelligence: An Overview
Ambient Intelligence: An Overview
 
Version Control with Git
Version Control with GitVersion Control with Git
Version Control with Git
 
LAM 2015 - Social Networks Technologies
LAM 2015 - Social Networks TechnologiesLAM 2015 - Social Networks Technologies
LAM 2015 - Social Networks Technologies
 
AmI 2015 - Python basics
AmI 2015 - Python basicsAmI 2015 - Python basics
AmI 2015 - Python basics
 
PowerOnt: an ontology-based approach for power consumption estimation in Smar...
PowerOnt: an ontology-based approach for power consumption estimation in Smar...PowerOnt: an ontology-based approach for power consumption estimation in Smar...
PowerOnt: an ontology-based approach for power consumption estimation in Smar...
 
Interacting with Smart Environments - Ph.D. Thesis Presentation
Interacting with Smart Environments - Ph.D. Thesis PresentationInteracting with Smart Environments - Ph.D. Thesis Presentation
Interacting with Smart Environments - Ph.D. Thesis Presentation
 
Semantic Web: an introduction
Semantic Web: an introductionSemantic Web: an introduction
Semantic Web: an introduction
 
Living in Smart Environments - 3rd year PhD Report
Living in Smart Environments - 3rd year PhD ReportLiving in Smart Environments - 3rd year PhD Report
Living in Smart Environments - 3rd year PhD Report
 
Semantic Web: an introduction
Semantic Web: an introductionSemantic Web: an introduction
Semantic Web: an introduction
 
Social Network Technologies
Social Network TechnologiesSocial Network Technologies
Social Network Technologies
 
Clean Code
Clean CodeClean Code
Clean Code
 
Living in Smart Environments - 2nd year PhD Report
Living in Smart Environments - 2nd year PhD ReportLiving in Smart Environments - 2nd year PhD Report
Living in Smart Environments - 2nd year PhD Report
 

Último

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Último (20)

HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 

Introduction to OpenCV

  • 1. 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/
  • 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  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
  • 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?  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
  • 16. 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
  • 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