SlideShare uma empresa Scribd logo
1 de 42
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-NC-SA)
License. To view a copy of this license, visit
http://creativecommons.org/licenses/by-nc-sa/4.0/
What is OpenCV?
 Computer Vision library
 Open Source (BSD License)
 http://opencv.org
 Originally developed by Intel
 With more than 2500 optimized algorithms
 Supports a lot of different languages
 C, C++, Python, and Java
 but is written natively in C++
 Cross platform
 also available for Android and iOS
10/18/2016 Introduction to OpenCV 2
What is OpenCV?
10/18/2016 Introduction to OpenCV 3
SSE, NEON, IPP, OpenCL, CUDA, etc.
core, imgproc, objdetect, etc.
face, text, etc.
Bindings: Python,
Java, …
Sample, tutorials
OpenCV
OpenCV
contrib
OpenCV
HAL
What is used for?
 Human-Computer Interaction (HCI)
 Object Identification
 Object Recognition
 Face Recognition
 Gesture Recognition
 Motion Tracking
 Image Processing
 Mobile Robotics
 … and so on
10/18/2016 Introduction to OpenCV 4
Why OpenCV (for this course)?
 We looked for a software/library:
 that covers most of Computer Vision techniques
 widely used or de-facto standard
 free/open, possibly
 in a language known by most students
 in which a GUI can be created
 able to handle real-time image processing
10/18/2016 Introduction to OpenCV 5
Alternatives?
10/18/2016 Introduction to OpenCV 6
vs.
OpenCV: pros
 Specificity
 OpenCV was made for computer vision/image
processing
 Matlab is quite generic
 Speed
 30+ frames processed per seconds in real time image
processing with OpenCV
 around 4-5 frames processed per seconds in real time
image processing with Matlab
 Efficiency
 Matlab needs more system resources than OpenCV
10/18/2016 Introduction to OpenCV 7
OpenCV: cons
 Easy of use
 Matlab won hands down!
 Integrated Development Environment (IDE)
 you can use Eclipse, Netbeans, Visual Studio, Qt,
XCode, … even a simple text editor for OpenCV
 Matlab has is own IDE
 Memory management
10/18/2016 Introduction to OpenCV 8
OpenCV: pros (final)
 Price (!)
 OpenCV Wrappers
 Emgu CV, ruby-opencv…
 More similar to industry-level frameworks
10/18/2016 Introduction to OpenCV 9
OpenCV in C++: why not?
 The OpenCV APIs have few capabilities for
user interfaces
 i.e., you can open a window with an image inside.
Do you want a button? You cannot have it!
 to have a “decent” user interface you need to
install “something else” (e.g., Qt for C++)…
 … and then compile OpenCV with Qt support
 C++ learning curve is quite… steep
 source: experiences from teaching this course in
the first years
10/18/2016 Introduction to OpenCV 10
OpenCV in C++: why not?
 OpenCV C++ APIs exist since OpenCV 1.0
 they dramatically changed starting from
OpenCV 2.0
 it is possible, but not recommended, to “mix”
different OpenCV version
 typically, it is a good way to get into trouble!
10/18/2016 Introduction to OpenCV 11
OpenCV in C++: why not?
 It is possible to use OpenCV C APIs together
with C++ APIs
 typically it is a good way to get into trouble!
 OpenCV 3.x is mostly compatible with
OpenCV 2.x
 but OpenCV 1.x API is deprecated and partially
removed
10/18/2016 Introduction to OpenCV 12
OpenCV in Java: why?
 OpenCV provides also Java APIs
 nothing to compile (on Windows)
 "easy" installation on macOS thanks to
Homebrew
 they works on Android, too
 Java 7/8 has a first-grade user interface
 not Swing, but JavaFX
 https://docs.oracle.com/javase/8/javase-
clienttechnologies.htm
10/18/2016 Introduction to OpenCV 13
OpenCV in Java: why?
 Almost everybody here should have some
(basic) experience with Java
 Performances between the C++ APIs and the
Java APIs are comparable
10/18/2016 Introduction to OpenCV 14
OpenCV in Java: why?
 The OpenCV Java APIs are really similar to the
C++ version
 knowledge can be transferred!
 examples:
 to store an image in memory both use the Mat object
 to write an image on disk both use the imwrite() method
 Something changes a bit
 examples:
 CV_RGB2GRAY (C++) becomes COLOR_RGB2GRAY (Java)
 Point, Point2d, Point2f (C++) becomes 3 overloaded
constructor of Point (Java)
10/18/2016 Introduction to OpenCV 15
OPENCV IN JAVA
Getting started…
10/18/2016 Introduction to OpenCV 16
OpenCV 3.x
 It is modular and extendible
 It includes mature and clean algorithms that
are fully supported
 A separate contribution repository is for new
algorithms that people want to share
10/18/2016 Introduction to OpenCV 17
OpenCV 3.x
contributions
OpenCV
3.x
OpenCV 2.x
Main Modules
10/18/2016 Introduction to OpenCV 18
 core
 basic structures and algorithms
 imgproc
 image processing algorithms (such as image filtering,
geometrical image transformations, histograms, etc.)
 videoio
 media I/O
OpenCV has a modular structure:
each package includes several shared or static libraries
New
Main Modules
10/18/2016 Introduction to OpenCV 19
 video
 video analysis (such as motion estimation and object
tracking)
 imgcodecs
 image file reading and writing
 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, …)
New
Main Modules
10/18/2016 Introduction to OpenCV 20
 highgui
 provides basic UI capabilities (in C, C++, and Python)
 ml
 machine learning classes used for statistical
classification, regression and clustering of data
 photo
 computational photography
 cuda*
 various modules with CUDA-optimized algorithms
New
Not available in Java
Data Structures
10/18/2016 Introduction to OpenCV 21
 We speak about Java APIs
 All the OpenCV classes and methods are placed
into the org.opencv.* packages
 Mat
 the primary image structure in OpenCV 2.x/3.x
 overcomes the “old” IplImage/CvMat problems
(OpenCV 1.x/C API)
 automatic memory management (more or less in C++)
 two data parts:
 matrix header (contains information about the matrix)
 a pointer to the matrix containing the pixel values
Duplicate Mat objects…
Mat first = Mat.eye(3, 3, CvType.CV_8U1C);
10/18/2016 Introduction to OpenCV 22
1 0 0
0 1 0
0 0 1
Header
first
Duplicate Mat objects…
Mat first = Mat.eye(3, 3, CvType.CV_8U1C);
Mat second = first;
10/18/2016 Introduction to OpenCV 23
1 0 0
0 1 0
0 0 1
Header
first
Header
second
Duplicate Mat objects…
Mat first = Mat.eye(3, 3, CvType.CV_8U1C);
Mat second = first;
first.put(0, 0, 2, 2, 2);
10/18/2016 Introduction to OpenCV 24
Header
first
Header
second
2 2 2
0 1 0
0 0 1
Duplicate Mat objects…
Mat first = Mat.eye(3, 3, CvType.CV_8U1C);
Mat second = new Mat();
second = first.clone(); // first.copyTo(second);
first.put(0, 0, 2, 2, 2);
10/18/2016 Introduction to OpenCV 25
2 2 2
0 1 0
0 0 1
Header
first
Header
second
1 0 0
0 1 0
0 0 1
Data Structures
10/18/2016 Introduction to OpenCV 26
 Point
 2D point
 defined by x, y coordinates
 Point first = new Point(2, 3);
 Size
 2D size structure
 specify the size (width and height) of an image
or rectangle
 Rect
 2D rectangle object
Basic Drawing Operations
10/18/2016 Introduction to OpenCV 27
 Imgproc.circle()
 draws a simple or filled circle with a given center and radius
on a given image
 Imgproc.line()
 draws a line between two point in the given image
 Imgproc.ellipse()
 draws an ellipse outline, a filled ellipse, an elliptic arc, a filled
ellipse sector, …
 Imgproc.rectangle()
 draws a rectangle outline or a filled rectangle
 note that negative thickness will fill the rectangle
Basic Image I/O
10/18/2016 Introduction to OpenCV 28
 Imgcodecs.imread()
 loads an image from file and return the corresponding
Mat object
Mat Imgcodecs.imread(String filename,
int flags)
 Imgcodecs.imwrite()
 save an image on disk
bool Imgcodecs.imwrite(String filename,
Mat img, MatOfInt params)
Color Spaces
10/18/2016 Introduction to OpenCV 29
 Imgproc.cvtColor
 converts an input image from one color space to another
 examples:
 cvtColor(src, dest, Imgproc.COLOR_RGB2GRAY);
 cvtColor(src, dest, Imgproc.COLOR_HSV2BGR);
 cvtColor(src, dest, Imgproc.COLOR_RGB2BGR);
 Important! Images in OpenCV uses BGR instead of
RGB
Getting started (without going crazy)
LET’S GET PRACTICAL!
10/18/2016 30 Introduction to OpenCV
How can we use OpenCV?
10/18/2016 Introduction to OpenCV 31
 LABINF:
 already installed under Windows
 Java 8 and OpenCV version 3.1
 Eclipse (Neon) is the IDE
 At home:
 we recommend Eclipse Neon, Java 8 and OpenCV
3.1
 feel free to use any Java IDE you like
 Installation:
 http://opencv-java-
tutorials.readthedocs.io/en/latest/01-installing-opencv-
for-java.html
What if I got problems?
10/18/2016 Introduction to OpenCV 32
 Small problems
 drop me a line
 luigi.derussis@polito.it
 Normal problems
 come to office hours
 please send an e-mail beforehand
 Enormous problems
 pray?
 no, seriously, we can schedule an extra “lesson”
Awesome student to me
Hi,
[…] I’m using “cvtColor(image, gray, COLOR_BGR2GRAY);” but it give this exception: […]
Can you help me?
Regards,
…
Problems with JavaFX and a gray scale image
What if I got problems?
10/18/2016 Introduction to OpenCV 33
 Small problems
 drop me a line
 luigi.derussis@polito.it
 Normal problems
 come to office hours
 please send an e-mail beforehand
 Enormous problems
 pray?
 no, seriously, we can schedule an extra “lesson”
Not-So-Awesome student to me
Hi,
[…] I followed the guide for installing OpenCV on my Mac but I have an error after step 3. Can
we meet on next Wednesday to solve the problem?
Thanks!
Regards,
…
OpenCV installation
What if I got problems?
10/18/2016 Introduction to OpenCV 34
 Small problems
 drop me a line
 luigi.derussis@polito.it
 Normal problems
 come to office hours
 please send an e-mail beforehand
 Enormous problems
 pray?
 no, seriously, we can schedule an extra “lesson”
Good student to me
Hi,
[…] I see the solution of Exercise 2.1 but I don’t understand the following expressions:
- main();
- System.out.println();
- @Override.
Can you explain to me what they are?
Regards,
…
Help with OpenCV
An e-mail not to be sent!
10/18/2016 Introduction to OpenCV 35
Useful Resources…
10/18/2016 Introduction to OpenCV 36
 OpenCV Wiki
 https://github.com/Itseez/opencv/wiki
 OpenCV Official Documentation
 http://docs.opencv.org/3.1.0/
 User Q&A forum
 http://answers.opencv.org/questions/
 OpenCV Javadocs
 http://docs.opencv.org/java/3.1.0/
 JavaFX Documentation
 https://docs.oracle.com/javase/8/javase-
clienttechnologies.htm
Useful Resources…
10/18/2016 Introduction to OpenCV 37
 Daniel Lélis Baggio, OpenCV 3.0 Computer
Vision with Java, PACKT Publishing, 2015,
ISBN 978-1-78328-397-2
 Gary Bradski, Adrian Kaehler, Learning
OpenCV 3 - Computer Vision in C++ with the
OpenCV Library, O'Reilly Media, TBP, ISBN
978-1-4919-3799-0
 Other books:
 http://opencv.org/books.html
Put everything together
DEMO HOUR
10/18/2016 38 Introduction to OpenCV
GUI? No, thanks
 Write a simple OpenCV program to:
1. create and print a 3x3 identity matrix
2. read an image from disk
3. convert the image in grayscale
4. save the grayscale image back on disk
10/18/2016 Introduction to OpenCV 39
OpenCV meets JavaFX (I)
 Write a graphical application with OpenCV to:
1. read an image from disk
2. convert it in grayscale
3. show the result on screen
10/18/2016 Introduction to OpenCV 40
OpenCV meets JavaFX (II)
 Write a graphical application with OpenCV to:
1. acquire the video stream from the webcam
2. convert it in grayscale
3. show the result of the acquisition on screen
10/18/2016 Introduction to OpenCV 41
License
18/10/2016 Computer Vision - Introduction 1 42
This work is licensed under the Creative Commons “Attribution-
NonCommercial-ShareAlike International (CC BY-NC-SA 4.0)”
License.
You are free to:
 Share - copy and redistribute the material in any medium or format
 Adapt - remix, transform, and build upon the material
for any purpose, even commercially.
Under the following terms:
 Attribution - You must give appropriate credit, provide a link to the
license, and indicate if changes were made. You may do so in any
reasonable manner, but not in any way that suggests the licensor
endorses you or your use.
 Noncommercial - You may not use the material for commercial
purposes.
 Share Alike - If you remix, transform, or build upon the material, you
must distribute your contributions under the same license as the
original.

Mais conteúdo relacionado

Mais procurados

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 RoadmapEugene Khvedchenya
 
PyCon 2012: Militarizing Your Backyard: Computer Vision and the Squirrel Hordes
PyCon 2012: Militarizing Your Backyard: Computer Vision and the Squirrel HordesPyCon 2012: Militarizing Your Backyard: Computer Vision and the Squirrel Hordes
PyCon 2012: Militarizing Your Backyard: Computer Vision and the Squirrel Hordeskgrandis
 
A high level introduction to OpenCV
A high level introduction to OpenCVA high level introduction to OpenCV
A high level introduction to OpenCVMax Tillich
 
Open Cv 2005 Q4 Tutorial
Open Cv 2005 Q4 TutorialOpen Cv 2005 Q4 Tutorial
Open Cv 2005 Q4 Tutorialantiw
 
openCV with python
openCV with pythonopenCV with python
openCV with pythonWei-Wen Hsu
 
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 vs2015Wei-Wen Hsu
 
OpenCV (Open source computer vision)
OpenCV (Open source computer vision)OpenCV (Open source computer vision)
OpenCV (Open source computer vision)Chetan Allapur
 
A basic introduction to open cv for image processing
A basic introduction to open cv for image processingA basic introduction to open cv for image processing
A basic introduction to open cv for image processingChu Lam
 
Computer Vision, Deep Learning, OpenCV
Computer Vision, Deep Learning, OpenCVComputer Vision, Deep Learning, OpenCV
Computer Vision, Deep Learning, OpenCVFarshid Pirahansiah
 
Introduction to OpenCV 2.3.1
Introduction to OpenCV 2.3.1Introduction to OpenCV 2.3.1
Introduction to OpenCV 2.3.1Luigi De Russis
 
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, Farshid Pirahansiah
 
Getting started with open cv in raspberry pi
Getting started with open cv in raspberry piGetting started with open cv in raspberry pi
Getting started with open cv in raspberry piJayaprakash Nagaruru
 
Cross Platform App Development with C++
Cross Platform App Development with C++Cross Platform App Development with C++
Cross Platform App Development with C++Joan Puig Sanz
 
Of complicacy of programming, or won't C# save us?
Of complicacy of programming, or won't C# save us?Of complicacy of programming, or won't C# save us?
Of complicacy of programming, or won't C# save us?PVS-Studio
 
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 beyonddividiti
 
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 CodeBlocksWei-Wen Hsu
 
Objective-C Runtime overview
Objective-C Runtime overviewObjective-C Runtime overview
Objective-C Runtime overviewFantageek
 

Mais procurados (20)

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
 
PyCon 2012: Militarizing Your Backyard: Computer Vision and the Squirrel Hordes
PyCon 2012: Militarizing Your Backyard: Computer Vision and the Squirrel HordesPyCon 2012: Militarizing Your Backyard: Computer Vision and the Squirrel Hordes
PyCon 2012: Militarizing Your Backyard: Computer Vision and the Squirrel Hordes
 
Facedetect
FacedetectFacedetect
Facedetect
 
A high level introduction to OpenCV
A high level introduction to OpenCVA high level introduction to OpenCV
A high level introduction to OpenCV
 
Open Cv 2005 Q4 Tutorial
Open Cv 2005 Q4 TutorialOpen Cv 2005 Q4 Tutorial
Open Cv 2005 Q4 Tutorial
 
Open cv with android
Open cv with androidOpen cv with android
Open cv with android
 
openCV with python
openCV with pythonopenCV with python
openCV with python
 
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
 
OpenCV (Open source computer vision)
OpenCV (Open source computer vision)OpenCV (Open source computer vision)
OpenCV (Open source computer vision)
 
A basic introduction to open cv for image processing
A basic introduction to open cv for image processingA basic introduction to open cv for image processing
A basic introduction to open cv for image processing
 
Computer Vision, Deep Learning, OpenCV
Computer Vision, Deep Learning, OpenCVComputer Vision, Deep Learning, OpenCV
Computer Vision, Deep Learning, OpenCV
 
Introduction to OpenCV 2.3.1
Introduction to OpenCV 2.3.1Introduction to OpenCV 2.3.1
Introduction to OpenCV 2.3.1
 
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,
 
Python Open CV
Python Open CVPython Open CV
Python Open CV
 
Getting started with open cv in raspberry pi
Getting started with open cv in raspberry piGetting started with open cv in raspberry pi
Getting started with open cv in raspberry pi
 
Cross Platform App Development with C++
Cross Platform App Development with C++Cross Platform App Development with C++
Cross Platform App Development with C++
 
Of complicacy of programming, or won't C# save us?
Of complicacy of programming, or won't C# save us?Of complicacy of programming, or won't C# save us?
Of complicacy of programming, or won't C# save us?
 
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
 
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
 
Objective-C Runtime overview
Objective-C Runtime overviewObjective-C Runtime overview
Objective-C Runtime overview
 

Destaque

Face Recognition using OpenCV
Face Recognition using OpenCVFace Recognition using OpenCV
Face Recognition using OpenCVVasile Chelban
 
Semantic Web - Ontology 101
Semantic Web - Ontology 101Semantic Web - Ontology 101
Semantic Web - Ontology 101Luigi De Russis
 
Programming the Semantic Web
Programming the Semantic WebProgramming the Semantic Web
Programming the Semantic WebLuigi De Russis
 
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-learnShiqiao Du
 

Destaque (6)

Face Recognition using OpenCV
Face Recognition using OpenCVFace Recognition using OpenCV
Face Recognition using OpenCV
 
Semantic Web - Ontology 101
Semantic Web - Ontology 101Semantic Web - Ontology 101
Semantic Web - Ontology 101
 
Programming the Semantic Web
Programming the Semantic WebProgramming the Semantic Web
Programming the Semantic Web
 
Jena Programming
Jena ProgrammingJena Programming
Jena Programming
 
Java and OWL
Java and OWLJava and OWL
Java and OWL
 
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
 

Semelhante a Introduction to OpenCV 3.x (with Java)

OpenCV @ Droidcon 2012
OpenCV @ Droidcon 2012OpenCV @ Droidcon 2012
OpenCV @ Droidcon 2012Wingston
 
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)IJERA Editor
 
Automatic License Plate Recognition using OpenCV
Automatic License Plate Recognition using OpenCVAutomatic License Plate Recognition using OpenCV
Automatic License Plate Recognition using OpenCVEditor IJCATR
 
Automatic License Plate Recognition using OpenCV
Automatic License Plate Recognition using OpenCV Automatic License Plate Recognition using OpenCV
Automatic License Plate Recognition using OpenCV Editor IJCATR
 
PVS-Studio advertisement - static analysis of C/C++ code
PVS-Studio advertisement - static analysis of C/C++ codePVS-Studio advertisement - static analysis of C/C++ code
PVS-Studio advertisement - static analysis of C/C++ codeAndrey Karpov
 
“OpenCV: Past, Present and Future,” a Presentation from OpenCV.org
“OpenCV: Past, Present and Future,” a Presentation from OpenCV.org“OpenCV: Past, Present and Future,” a Presentation from OpenCV.org
“OpenCV: Past, Present and Future,” a Presentation from OpenCV.orgEdge AI and Vision Alliance
 
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 CodeAndrzej Wasowski
 
Разработка кросс-платформенного кода между iPhone < -> Windows с помощью o...
Разработка кросс-платформенного кода между iPhone < -> Windows с помощью o...Разработка кросс-платформенного кода между iPhone < -> Windows с помощью o...
Разработка кросс-платформенного кода между iPhone < -> Windows с помощью o...Yandex
 
Unit 1 of c++ part 1 basic introduction
Unit 1 of c++ part 1 basic introductionUnit 1 of c++ part 1 basic introduction
Unit 1 of c++ part 1 basic introductionAKR Education
 
Introduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdfIntroduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdfAnassElHousni
 
DIY: Computer Vision with GWT.
DIY: Computer Vision with GWT.DIY: Computer Vision with GWT.
DIY: Computer Vision with GWT.JooinK
 
DIY- computer vision with GWT
DIY- computer vision with GWTDIY- computer vision with GWT
DIY- computer vision with GWTFrancesca Tosi
 
Starting with OpenCV on i.MX 6 Processors
Starting with OpenCV on i.MX 6 ProcessorsStarting with OpenCV on i.MX 6 Processors
Starting with OpenCV on i.MX 6 ProcessorsToradex
 
OpenACC Monthly Highlights: July 2020
OpenACC Monthly Highlights: July 2020OpenACC Monthly Highlights: July 2020
OpenACC Monthly Highlights: July 2020OpenACC
 
The essence of the VivaCore code analysis library
The essence of the VivaCore code analysis libraryThe essence of the VivaCore code analysis library
The essence of the VivaCore code analysis libraryPVS-Studio
 

Semelhante a Introduction to OpenCV 3.x (with Java) (20)

Opencv
OpencvOpencv
Opencv
 
OpenCV @ Droidcon 2012
OpenCV @ Droidcon 2012OpenCV @ Droidcon 2012
OpenCV @ Droidcon 2012
 
Introduction to OpenCV
Introduction to OpenCVIntroduction to OpenCV
Introduction to OpenCV
 
OpenCV+Android.pptx
OpenCV+Android.pptxOpenCV+Android.pptx
OpenCV+Android.pptx
 
C++Basics2022.pptx
C++Basics2022.pptxC++Basics2022.pptx
C++Basics2022.pptx
 
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
 
PVS-Studio advertisement - static analysis of C/C++ code
PVS-Studio advertisement - static analysis of C/C++ codePVS-Studio advertisement - static analysis of C/C++ code
PVS-Studio advertisement - static analysis of C/C++ code
 
“OpenCV: Past, Present and Future,” a Presentation from OpenCV.org
“OpenCV: Past, Present and Future,” a Presentation from OpenCV.org“OpenCV: Past, Present and Future,” a Presentation from OpenCV.org
“OpenCV: Past, Present and Future,” a Presentation from OpenCV.org
 
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
 
Разработка кросс-платформенного кода между iPhone < -> Windows с помощью o...
Разработка кросс-платформенного кода между iPhone < -> Windows с помощью o...Разработка кросс-платформенного кода между iPhone < -> Windows с помощью o...
Разработка кросс-платформенного кода между iPhone < -> Windows с помощью o...
 
Unit 1 of c++ part 1 basic introduction
Unit 1 of c++ part 1 basic introductionUnit 1 of c++ part 1 basic introduction
Unit 1 of c++ part 1 basic introduction
 
Introduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdfIntroduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdf
 
DIY: Computer Vision with GWT.
DIY: Computer Vision with GWT.DIY: Computer Vision with GWT.
DIY: Computer Vision with GWT.
 
DIY- computer vision with GWT
DIY- computer vision with GWTDIY- computer vision with GWT
DIY- computer vision with GWT
 
Starting with OpenCV on i.MX 6 Processors
Starting with OpenCV on i.MX 6 ProcessorsStarting with OpenCV on i.MX 6 Processors
Starting with OpenCV on i.MX 6 Processors
 
OpenACC Monthly Highlights: July 2020
OpenACC Monthly Highlights: July 2020OpenACC Monthly Highlights: July 2020
OpenACC Monthly Highlights: July 2020
 
The essence of the VivaCore code analysis library
The essence of the VivaCore code analysis libraryThe essence of the VivaCore code analysis library
The essence of the VivaCore code analysis library
 
resume
resumeresume
resume
 

Mais de Luigi De Russis

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 SpeechLuigi De Russis
 
Semantic Web: an Introduction
Semantic Web: an IntroductionSemantic Web: an Introduction
Semantic Web: an IntroductionLuigi De Russis
 
AmI 2017 - Python intermediate
AmI 2017 - Python intermediateAmI 2017 - Python intermediate
AmI 2017 - Python intermediateLuigi De Russis
 
AmI 2017 - Python basics
AmI 2017 - Python basicsAmI 2017 - Python basics
AmI 2017 - Python basicsLuigi De Russis
 
AngularJS: an introduction
AngularJS: an introductionAngularJS: an introduction
AngularJS: an introductionLuigi De Russis
 
AmI 2016 - Python basics
AmI 2016 - Python basicsAmI 2016 - Python basics
AmI 2016 - Python basicsLuigi De Russis
 
Ambient Intelligence: An Overview
Ambient Intelligence: An OverviewAmbient Intelligence: An Overview
Ambient Intelligence: An OverviewLuigi De Russis
 
Version Control with Git
Version Control with GitVersion Control with Git
Version Control with GitLuigi De Russis
 
LAM 2015 - Social Networks Technologies
LAM 2015 - Social Networks TechnologiesLAM 2015 - Social Networks Technologies
LAM 2015 - Social Networks TechnologiesLuigi De Russis
 
AmI 2015 - Python basics
AmI 2015 - Python basicsAmI 2015 - Python basics
AmI 2015 - Python basicsLuigi De Russis
 
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...Luigi De Russis
 
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 PresentationLuigi De Russis
 
Semantic Web: an introduction
Semantic Web: an introductionSemantic Web: an introduction
Semantic Web: an introductionLuigi De Russis
 
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 ReportLuigi De Russis
 
Semantic Web: an introduction
Semantic Web: an introductionSemantic Web: an introduction
Semantic Web: an introductionLuigi De Russis
 
Social Network Technologies
Social Network TechnologiesSocial Network Technologies
Social Network TechnologiesLuigi De Russis
 
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 ReportLuigi De Russis
 
dWatch: a Personal Wrist Watch for Smart Environments
dWatch: a Personal Wrist Watch for Smart EnvironmentsdWatch: a Personal Wrist Watch for Smart Environments
dWatch: a Personal Wrist Watch for Smart EnvironmentsLuigi De Russis
 
Version Control with Git
Version Control with GitVersion Control with Git
Version Control with GitLuigi 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
 
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
 
dWatch: a Personal Wrist Watch for Smart Environments
dWatch: a Personal Wrist Watch for Smart EnvironmentsdWatch: a Personal Wrist Watch for Smart Environments
dWatch: a Personal Wrist Watch for Smart Environments
 
Version Control with Git
Version Control with GitVersion Control with Git
Version Control with Git
 

Último

unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 

Último (20)

unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 

Introduction to OpenCV 3.x (with Java)

  • 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-NC-SA) License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/
  • 2. What is OpenCV?  Computer Vision library  Open Source (BSD License)  http://opencv.org  Originally developed by Intel  With more than 2500 optimized algorithms  Supports a lot of different languages  C, C++, Python, and Java  but is written natively in C++  Cross platform  also available for Android and iOS 10/18/2016 Introduction to OpenCV 2
  • 3. What is OpenCV? 10/18/2016 Introduction to OpenCV 3 SSE, NEON, IPP, OpenCL, CUDA, etc. core, imgproc, objdetect, etc. face, text, etc. Bindings: Python, Java, … Sample, tutorials OpenCV OpenCV contrib OpenCV HAL
  • 4. What is used for?  Human-Computer Interaction (HCI)  Object Identification  Object Recognition  Face Recognition  Gesture Recognition  Motion Tracking  Image Processing  Mobile Robotics  … and so on 10/18/2016 Introduction to OpenCV 4
  • 5. Why OpenCV (for this course)?  We looked for a software/library:  that covers most of Computer Vision techniques  widely used or de-facto standard  free/open, possibly  in a language known by most students  in which a GUI can be created  able to handle real-time image processing 10/18/2016 Introduction to OpenCV 5
  • 7. OpenCV: pros  Specificity  OpenCV was made for computer vision/image processing  Matlab is quite generic  Speed  30+ frames processed per seconds in real time image processing with OpenCV  around 4-5 frames processed per seconds in real time image processing with Matlab  Efficiency  Matlab needs more system resources than OpenCV 10/18/2016 Introduction to OpenCV 7
  • 8. OpenCV: cons  Easy of use  Matlab won hands down!  Integrated Development Environment (IDE)  you can use Eclipse, Netbeans, Visual Studio, Qt, XCode, … even a simple text editor for OpenCV  Matlab has is own IDE  Memory management 10/18/2016 Introduction to OpenCV 8
  • 9. OpenCV: pros (final)  Price (!)  OpenCV Wrappers  Emgu CV, ruby-opencv…  More similar to industry-level frameworks 10/18/2016 Introduction to OpenCV 9
  • 10. OpenCV in C++: why not?  The OpenCV APIs have few capabilities for user interfaces  i.e., you can open a window with an image inside. Do you want a button? You cannot have it!  to have a “decent” user interface you need to install “something else” (e.g., Qt for C++)…  … and then compile OpenCV with Qt support  C++ learning curve is quite… steep  source: experiences from teaching this course in the first years 10/18/2016 Introduction to OpenCV 10
  • 11. OpenCV in C++: why not?  OpenCV C++ APIs exist since OpenCV 1.0  they dramatically changed starting from OpenCV 2.0  it is possible, but not recommended, to “mix” different OpenCV version  typically, it is a good way to get into trouble! 10/18/2016 Introduction to OpenCV 11
  • 12. OpenCV in C++: why not?  It is possible to use OpenCV C APIs together with C++ APIs  typically it is a good way to get into trouble!  OpenCV 3.x is mostly compatible with OpenCV 2.x  but OpenCV 1.x API is deprecated and partially removed 10/18/2016 Introduction to OpenCV 12
  • 13. OpenCV in Java: why?  OpenCV provides also Java APIs  nothing to compile (on Windows)  "easy" installation on macOS thanks to Homebrew  they works on Android, too  Java 7/8 has a first-grade user interface  not Swing, but JavaFX  https://docs.oracle.com/javase/8/javase- clienttechnologies.htm 10/18/2016 Introduction to OpenCV 13
  • 14. OpenCV in Java: why?  Almost everybody here should have some (basic) experience with Java  Performances between the C++ APIs and the Java APIs are comparable 10/18/2016 Introduction to OpenCV 14
  • 15. OpenCV in Java: why?  The OpenCV Java APIs are really similar to the C++ version  knowledge can be transferred!  examples:  to store an image in memory both use the Mat object  to write an image on disk both use the imwrite() method  Something changes a bit  examples:  CV_RGB2GRAY (C++) becomes COLOR_RGB2GRAY (Java)  Point, Point2d, Point2f (C++) becomes 3 overloaded constructor of Point (Java) 10/18/2016 Introduction to OpenCV 15
  • 16. OPENCV IN JAVA Getting started… 10/18/2016 Introduction to OpenCV 16
  • 17. OpenCV 3.x  It is modular and extendible  It includes mature and clean algorithms that are fully supported  A separate contribution repository is for new algorithms that people want to share 10/18/2016 Introduction to OpenCV 17 OpenCV 3.x contributions OpenCV 3.x OpenCV 2.x
  • 18. Main Modules 10/18/2016 Introduction to OpenCV 18  core  basic structures and algorithms  imgproc  image processing algorithms (such as image filtering, geometrical image transformations, histograms, etc.)  videoio  media I/O OpenCV has a modular structure: each package includes several shared or static libraries New
  • 19. Main Modules 10/18/2016 Introduction to OpenCV 19  video  video analysis (such as motion estimation and object tracking)  imgcodecs  image file reading and writing  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, …) New
  • 20. Main Modules 10/18/2016 Introduction to OpenCV 20  highgui  provides basic UI capabilities (in C, C++, and Python)  ml  machine learning classes used for statistical classification, regression and clustering of data  photo  computational photography  cuda*  various modules with CUDA-optimized algorithms New Not available in Java
  • 21. Data Structures 10/18/2016 Introduction to OpenCV 21  We speak about Java APIs  All the OpenCV classes and methods are placed into the org.opencv.* packages  Mat  the primary image structure in OpenCV 2.x/3.x  overcomes the “old” IplImage/CvMat problems (OpenCV 1.x/C API)  automatic memory management (more or less in C++)  two data parts:  matrix header (contains information about the matrix)  a pointer to the matrix containing the pixel values
  • 22. Duplicate Mat objects… Mat first = Mat.eye(3, 3, CvType.CV_8U1C); 10/18/2016 Introduction to OpenCV 22 1 0 0 0 1 0 0 0 1 Header first
  • 23. Duplicate Mat objects… Mat first = Mat.eye(3, 3, CvType.CV_8U1C); Mat second = first; 10/18/2016 Introduction to OpenCV 23 1 0 0 0 1 0 0 0 1 Header first Header second
  • 24. Duplicate Mat objects… Mat first = Mat.eye(3, 3, CvType.CV_8U1C); Mat second = first; first.put(0, 0, 2, 2, 2); 10/18/2016 Introduction to OpenCV 24 Header first Header second 2 2 2 0 1 0 0 0 1
  • 25. Duplicate Mat objects… Mat first = Mat.eye(3, 3, CvType.CV_8U1C); Mat second = new Mat(); second = first.clone(); // first.copyTo(second); first.put(0, 0, 2, 2, 2); 10/18/2016 Introduction to OpenCV 25 2 2 2 0 1 0 0 0 1 Header first Header second 1 0 0 0 1 0 0 0 1
  • 26. Data Structures 10/18/2016 Introduction to OpenCV 26  Point  2D point  defined by x, y coordinates  Point first = new Point(2, 3);  Size  2D size structure  specify the size (width and height) of an image or rectangle  Rect  2D rectangle object
  • 27. Basic Drawing Operations 10/18/2016 Introduction to OpenCV 27  Imgproc.circle()  draws a simple or filled circle with a given center and radius on a given image  Imgproc.line()  draws a line between two point in the given image  Imgproc.ellipse()  draws an ellipse outline, a filled ellipse, an elliptic arc, a filled ellipse sector, …  Imgproc.rectangle()  draws a rectangle outline or a filled rectangle  note that negative thickness will fill the rectangle
  • 28. Basic Image I/O 10/18/2016 Introduction to OpenCV 28  Imgcodecs.imread()  loads an image from file and return the corresponding Mat object Mat Imgcodecs.imread(String filename, int flags)  Imgcodecs.imwrite()  save an image on disk bool Imgcodecs.imwrite(String filename, Mat img, MatOfInt params)
  • 29. Color Spaces 10/18/2016 Introduction to OpenCV 29  Imgproc.cvtColor  converts an input image from one color space to another  examples:  cvtColor(src, dest, Imgproc.COLOR_RGB2GRAY);  cvtColor(src, dest, Imgproc.COLOR_HSV2BGR);  cvtColor(src, dest, Imgproc.COLOR_RGB2BGR);  Important! Images in OpenCV uses BGR instead of RGB
  • 30. Getting started (without going crazy) LET’S GET PRACTICAL! 10/18/2016 30 Introduction to OpenCV
  • 31. How can we use OpenCV? 10/18/2016 Introduction to OpenCV 31  LABINF:  already installed under Windows  Java 8 and OpenCV version 3.1  Eclipse (Neon) is the IDE  At home:  we recommend Eclipse Neon, Java 8 and OpenCV 3.1  feel free to use any Java IDE you like  Installation:  http://opencv-java- tutorials.readthedocs.io/en/latest/01-installing-opencv- for-java.html
  • 32. What if I got problems? 10/18/2016 Introduction to OpenCV 32  Small problems  drop me a line  luigi.derussis@polito.it  Normal problems  come to office hours  please send an e-mail beforehand  Enormous problems  pray?  no, seriously, we can schedule an extra “lesson” Awesome student to me Hi, […] I’m using “cvtColor(image, gray, COLOR_BGR2GRAY);” but it give this exception: […] Can you help me? Regards, … Problems with JavaFX and a gray scale image
  • 33. What if I got problems? 10/18/2016 Introduction to OpenCV 33  Small problems  drop me a line  luigi.derussis@polito.it  Normal problems  come to office hours  please send an e-mail beforehand  Enormous problems  pray?  no, seriously, we can schedule an extra “lesson” Not-So-Awesome student to me Hi, […] I followed the guide for installing OpenCV on my Mac but I have an error after step 3. Can we meet on next Wednesday to solve the problem? Thanks! Regards, … OpenCV installation
  • 34. What if I got problems? 10/18/2016 Introduction to OpenCV 34  Small problems  drop me a line  luigi.derussis@polito.it  Normal problems  come to office hours  please send an e-mail beforehand  Enormous problems  pray?  no, seriously, we can schedule an extra “lesson” Good student to me Hi, […] I see the solution of Exercise 2.1 but I don’t understand the following expressions: - main(); - System.out.println(); - @Override. Can you explain to me what they are? Regards, … Help with OpenCV
  • 35. An e-mail not to be sent! 10/18/2016 Introduction to OpenCV 35
  • 36. Useful Resources… 10/18/2016 Introduction to OpenCV 36  OpenCV Wiki  https://github.com/Itseez/opencv/wiki  OpenCV Official Documentation  http://docs.opencv.org/3.1.0/  User Q&A forum  http://answers.opencv.org/questions/  OpenCV Javadocs  http://docs.opencv.org/java/3.1.0/  JavaFX Documentation  https://docs.oracle.com/javase/8/javase- clienttechnologies.htm
  • 37. Useful Resources… 10/18/2016 Introduction to OpenCV 37  Daniel Lélis Baggio, OpenCV 3.0 Computer Vision with Java, PACKT Publishing, 2015, ISBN 978-1-78328-397-2  Gary Bradski, Adrian Kaehler, Learning OpenCV 3 - Computer Vision in C++ with the OpenCV Library, O'Reilly Media, TBP, ISBN 978-1-4919-3799-0  Other books:  http://opencv.org/books.html
  • 38. Put everything together DEMO HOUR 10/18/2016 38 Introduction to OpenCV
  • 39. GUI? No, thanks  Write a simple OpenCV program to: 1. create and print a 3x3 identity matrix 2. read an image from disk 3. convert the image in grayscale 4. save the grayscale image back on disk 10/18/2016 Introduction to OpenCV 39
  • 40. OpenCV meets JavaFX (I)  Write a graphical application with OpenCV to: 1. read an image from disk 2. convert it in grayscale 3. show the result on screen 10/18/2016 Introduction to OpenCV 40
  • 41. OpenCV meets JavaFX (II)  Write a graphical application with OpenCV to: 1. acquire the video stream from the webcam 2. convert it in grayscale 3. show the result of the acquisition on screen 10/18/2016 Introduction to OpenCV 41
  • 42. License 18/10/2016 Computer Vision - Introduction 1 42 This work is licensed under the Creative Commons “Attribution- NonCommercial-ShareAlike International (CC BY-NC-SA 4.0)” License. You are free to:  Share - copy and redistribute the material in any medium or format  Adapt - remix, transform, and build upon the material for any purpose, even commercially. Under the following terms:  Attribution - You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.  Noncommercial - You may not use the material for commercial purposes.  Share Alike - If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.