SlideShare uma empresa Scribd logo
1 de 35
Baixar para ler offline
Computer Vision

Luigi De Russis

Introduction to
OpenCV
2

OpenC… what?
OpenCV in brief

Introduction to OpenCV

07/11/2013
What is OpenCV?
3



Open source Computer Vision library
BSD License
 http://opencv.org






Originally developed by Intel
Has more than 2500 optimized algorithms
Supports a lot of different languages
C, C++, Python, Java
 but is written natively in C++




Cross platform


also available for Android and iOS

Introduction to OpenCV

07/11/2013
What it is used for?
4













Human-Computer Interaction (HCI)
Object Identification
Object Recognition
Face Recognition
Gesture Recognition
Motion Tracking
Image Processing
Mobile Robotics
… and so on

Introduction to OpenCV

07/11/2013
5

Motivations - OpenCV
Always ask “why?”

Introduction to OpenCV

07/11/2013
Why OpenCV?
6

vs.

Introduction to OpenCV

07/11/2013
OpenCV: pros
7



Specificity
 OpenCV

was made for 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


Efficient
 Matlab

Introduction to OpenCV

needs more system resources than OpenCV
07/11/2013
OpenCV: cons
8



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

Introduction to OpenCV

07/11/2013
OpenCV: pros (final)
9





Price (!)
OpenCV Wrappers
 SimpleCV,



Emgu CV, ruby-opencv…

More similar to industry-level frameworks

Introduction to OpenCV

07/11/2013
10

Motivation - Java
When Java meets OpenCV

Introduction to OpenCV

07/11/2013
Some facts…
11



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 for adding Qt support


C++ learning curve is quite… steep
 source:

experiences from teaching this course in the last

years
Introduction to OpenCV

07/11/2013
Some (other) facts…
12



OpenCV C++ APIs exists since OpenCV 1.0
 It

is possible, but not recommended, to “mix” different
OpenCV version
 Typically, it is a good way to get into trouble!


It is possible to use OpenCV C APIs together with
C++ APIs
 Typically

Introduction to OpenCV

it is a good way to get into trouble!

07/11/2013
Some (other) facts…
13



OpenCV C++ API exists since OpenCV 1.0
 It

is possible, but not recommended, to “mix” different
OpenCV version
 Typically, it is a good way to get into trouble!

Yeah, some students did it!



It is possible to use OpenCV C APIs together with
C++ APIs
 Typically

Introduction to OpenCV

it is a good way to get into trouble!

07/11/2013
A better world is possible?
14



OpenCV provides also the Java APIs
nothing to compile (on Windows)
 they works on Android, also




Java 7 has a first-grade user interface
not Swing, but JavaFX
 http://www.oracle.com/technetwork/java/javafx






Almost everybody here should have some (basic)
experience with Java
Performance between the C++ APIs and the Java APIs
are comparable

Introduction to OpenCV

07/11/2013
A better world is possible?
15



The OpenCV Java APIs are almost identical 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 change a bit


examples:


CV_RGB2GRAY (C++) becomes COLOR_RGB2GRAY (Java)



Point, Point2d, Point2f (C++) becomes 3 overloaded
constructor of Point (Java)

Introduction to OpenCV

07/11/2013
A better world is possible?
16



Question:
 is

OpenCV with Java/JavaFX the “best” solution for
every application?

Introduction to OpenCV

07/11/2013
A better world is possible?
17



Question:
 is

OpenCV with Java/JavaFX the “best” solution for
every application?



Response:
 No,

obviously
 Do you need a GUI? Go with JavaFX!
 Do you have memory constraint? Go with C/C++!
…
 Please, no extremism!
Introduction to OpenCV

07/11/2013
18

OpenCV meets Java
Getting started with OpenCV and Java

Introduction to OpenCV

07/11/2013
Modules
19

OpenCV has a modular structure:
the package includes several shared or static libraries


core




imgproc




basic structures and algorithms
image processing algorithms (such as image filtering,
geometrical image transformations, histograms, etc.)

video


video analysis (such as motion estimation and object
tracking)

Introduction to OpenCV

07/11/2013
Modules
20



highgui




calib3d




camera calibration and 3D reconstruction

features2d




basic operation to read/write/encode images; in C, C++
and Python it provides also basic UI capabilities

2D features framework (feature detectors, descriptors, and
descriptor matchers)

objdetect


detection of objects and other items (e.g., faces, eyes, mugs,
people, …)

Introduction to OpenCV

07/11/2013
Modules
21



ml
 machine

learning classes used for statistical
classification, regression and clustering of data



gpu
 GPU-accelerated



photo
 computational



algorithms

photography

ccl
 OpenCL-accelerated

Introduction to OpenCV

algorithms
07/11/2013
Data Structures
22







We speak about Java API
All the OpenCV classes and methods are placed into
the org.opencv.* packages
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 in C++)
 two data parts:
matrix header (contains information about the matrix)
 a pointer to the matrix containing the pixel values


Introduction to OpenCV

07/11/2013
Data Structures
23



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

Introduction to OpenCV

07/11/2013
Basic Image I/O
24



Highgui.imread
 loads an image from file and return the corresponding Mat
object
Mat Highgui.imread(String filename,
int flags)



Highui.imwrite


save an image on disk
bool Highgui.imwrite(String filename,
Mat img, MatOfInt params)

Introduction to OpenCV

07/11/2013
Basic Drawing Operations
25









Core.circle
 draws a simple or filled circle with a given center and radius on a
given image
Core.line
 draws a line between two point in the given image
Core.ellipse
 draws an ellipse outline, a filled ellipse, an elliptic arc, a filled
ellipse sector, …
Core.rectangle
 draws a rectangle outline or a filled rectangle
 note that negative thickness will fill the rectangle

Introduction to OpenCV

07/11/2013
Color Spaces
26



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

Introduction to OpenCV

07/11/2013
27

Let’s get practical!
Getting started (without going crazy)

Introduction to OpenCV

07/11/2013
How can we use OpenCV?
28



LABINF:
 already

installed under Windows
 version 2.4.6
 Eclipse (Kepler) is the IDE


At home:
 you

can use whatever IDE you like
 but we give full support only for Eclipse


Installation:
 see

the PDF document in the teaching portal

Introduction to OpenCV

07/11/2013
What if I got problems?
29



Small problems


drop me a line




luigi.derussis@polito.it

Normal problems

Problems with JavaFX and a gray scale image

Awesome student to me
Hi,
[…] I’m using “cvtColor(image, gray, COLOR_BGR2GRAY);” but it give this exception: […]
Can you help me?

come to office hours
 every Wednesday, 9:00 - 11:00
 LAB6, second floor of DAUIN
 please send an e-mail beforehand




Regards,
…

Enormous problems
pray?
 no, seriously, we can schedule an extra “lesson”


Introduction to OpenCV

07/11/2013
What if I got problems?
30

OpenCV installation



Small problems


drop me a line




luigi.derussis@polito.it

Normal problems

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,
…

come to office hours
 every Wednesday, 9:00 - 11:00
 LAB6, second floor of DAUIN
 please send an e-mail beforehand




Enormous problems
pray?
 no, seriously, we can schedule an extra “lesson”


Introduction to OpenCV

07/11/2013
What if I got problems?
31



Small problems


drop me a line




luigi.derussis@polito.it

Normal problems
come to office hours
 every Wednesday, 9:00 - 11:00
 LAB6, second floor of DAUIN
 please send an e-mail beforehand


Help with OpenCV

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?



Enormous problems

Regards,
…

pray?
 no, seriously, we can schedule an extra “lesson”


Introduction to OpenCV

07/11/2013
An e-mail not to be sent!
32

Introduction to OpenCV

07/11/2013
Useful Resources…
33



OpenCV Wiki




OpenCV Official Documentation




http://answers.opencv.org/questions/

OpenCV Javadocs




http://docs.opencv.org/

User Q&A forum




http://code.opencv.org/projects/opencv/wiki

http://docs.opencv.org/java/

JavaFX Documentation


http://www.oracle.com/technetwork/java/javafx/document
ation

Introduction to OpenCV

07/11/2013
34

Demo Hour
Put everything together

Introduction to OpenCV

07/11/2013
License
35





This work is licensed under the Creative Commons “AttributionNonCommercial-ShareAlike Unported (CC BY-NC-SA 3,0)” License.
You are free:





Under the following conditions:







to Share - to copy, distribute and transmit the work
to Remix - to adapt the work

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.

To view a copy of this license, visit
http://creativecommons.org/licenses/by-nc-sa/3.0/

Introduction to OpenCV

07/11/2013

Mais conteúdo relacionado

Mais procurados

Social Networking Site in JAVA
Social Networking Site in JAVASocial Networking Site in JAVA
Social Networking Site in JAVA
PAS Softech Pvt. Ltd.
 

Mais procurados (20)

Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Core java report
Core java reportCore java report
Core java report
 
Disease prediction and doctor recommendation system
Disease prediction and doctor recommendation systemDisease prediction and doctor recommendation system
Disease prediction and doctor recommendation system
 
Jdbc connectivity in java
Jdbc connectivity in javaJdbc connectivity in java
Jdbc connectivity in java
 
Social Networking Site in JAVA
Social Networking Site in JAVASocial Networking Site in JAVA
Social Networking Site in JAVA
 
Opencv
OpencvOpencv
Opencv
 
History of java'
History of java'History of java'
History of java'
 
JDBC Architecture and Drivers
JDBC Architecture and DriversJDBC Architecture and Drivers
JDBC Architecture and Drivers
 
Human age and gender Detection
Human age and gender DetectionHuman age and gender Detection
Human age and gender Detection
 
Java language is different from other programming languages, How?
Java language is different  from other programming languages, How?Java language is different  from other programming languages, How?
Java language is different from other programming languages, How?
 
Operators used in vb.net
Operators used in vb.netOperators used in vb.net
Operators used in vb.net
 
Java PPT
Java PPTJava PPT
Java PPT
 
JRE , JDK and platform independent nature of JAVA
JRE , JDK and platform independent nature of JAVAJRE , JDK and platform independent nature of JAVA
JRE , JDK and platform independent nature of JAVA
 
Face recognisation system
Face recognisation systemFace recognisation system
Face recognisation system
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
 
Dog Breed Classification Using Part Localization
Dog Breed Classification Using Part LocalizationDog Breed Classification Using Part Localization
Dog Breed Classification Using Part Localization
 
IRJET- Detection and Classification of Skin Diseases using Different Colo...
IRJET-  	  Detection and Classification of Skin Diseases using Different Colo...IRJET-  	  Detection and Classification of Skin Diseases using Different Colo...
IRJET- Detection and Classification of Skin Diseases using Different Colo...
 
Java features
Java featuresJava features
Java features
 
Recent Progress on Object Detection_20170331
Recent Progress on Object Detection_20170331Recent Progress on Object Detection_20170331
Recent Progress on Object Detection_20170331
 
PPT on BRAIN TUMOR detection in MRI images based on IMAGE SEGMENTATION
PPT on BRAIN TUMOR detection in MRI images based on  IMAGE SEGMENTATION PPT on BRAIN TUMOR detection in MRI images based on  IMAGE SEGMENTATION
PPT on BRAIN TUMOR detection in MRI images based on IMAGE SEGMENTATION
 

Destaque

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
kgrandis
 

Destaque (8)

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
 
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)
 
Jena Programming
Jena ProgrammingJena Programming
Jena Programming
 
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
 
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
 
Java and OWL
Java and OWLJava and OWL
Java and OWL
 

Semelhante a Introduction to OpenCV (with Java)

"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
 
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
 
502021435-12345678Minor-Project-Ppt.pptx
502021435-12345678Minor-Project-Ppt.pptx502021435-12345678Minor-Project-Ppt.pptx
502021435-12345678Minor-Project-Ppt.pptx
shrey4922
 
Making php see, confoo 2011
Making php see, confoo 2011 Making php see, confoo 2011
Making php see, confoo 2011
Bachkoutou Toutou
 
JavaProgrammingForBeginners-Presentation.pdf
JavaProgrammingForBeginners-Presentation.pdfJavaProgrammingForBeginners-Presentation.pdf
JavaProgrammingForBeginners-Presentation.pdf
Sathwika7
 

Semelhante a Introduction to OpenCV (with Java) (20)

OpenCV (Open source computer vision)
OpenCV (Open source computer vision)OpenCV (Open source computer vision)
OpenCV (Open source computer vision)
 
"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...
 
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)
 
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
 
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
 
“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
 
Open cv python tutorial for beginners 1
Open cv python tutorial for beginners 1Open cv python tutorial for beginners 1
Open cv python tutorial for beginners 1
 
PL-4043, Accelerating OpenVL for Heterogeneous Platforms, by Gregor Miller
PL-4043, Accelerating OpenVL for Heterogeneous Platforms, by Gregor MillerPL-4043, Accelerating OpenVL for Heterogeneous Platforms, by Gregor Miller
PL-4043, Accelerating OpenVL for Heterogeneous Platforms, by Gregor Miller
 
_OOP with JAVA Solution Manual (1).pdf
_OOP with JAVA Solution Manual (1).pdf_OOP with JAVA Solution Manual (1).pdf
_OOP with JAVA Solution Manual (1).pdf
 
502021435-12345678Minor-Project-Ppt.pptx
502021435-12345678Minor-Project-Ppt.pptx502021435-12345678Minor-Project-Ppt.pptx
502021435-12345678Minor-Project-Ppt.pptx
 
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
 
00 intro to java
00 intro to java00 intro to java
00 intro to java
 
OpenCV @ Droidcon 2012
OpenCV @ Droidcon 2012OpenCV @ Droidcon 2012
OpenCV @ Droidcon 2012
 
8 Principles for Enabling Build/Measure/Learn: Lean Engineering in Action
8 Principles for Enabling Build/Measure/Learn: Lean Engineering in Action8 Principles for Enabling Build/Measure/Learn: Lean Engineering in Action
8 Principles for Enabling Build/Measure/Learn: Lean Engineering in Action
 
PVS-Studio confesses its love for Linux
PVS-Studio confesses its love for LinuxPVS-Studio confesses its love for Linux
PVS-Studio confesses its love for Linux
 
Making php see, confoo 2011
Making php see, confoo 2011 Making php see, confoo 2011
Making php see, confoo 2011
 
JavaProgrammingForBeginners-Presentation.pdf
JavaProgrammingForBeginners-Presentation.pdfJavaProgrammingForBeginners-Presentation.pdf
JavaProgrammingForBeginners-Presentation.pdf
 
The genesis of clusterlib - An open source library to tame your favourite sup...
The genesis of clusterlib - An open source library to tame your favourite sup...The genesis of clusterlib - An open source library to tame your favourite sup...
The genesis of clusterlib - An open source library to tame your favourite sup...
 

Mais de Luigi De Russis

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
 

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
 
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
 
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
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 

Introduction to OpenCV (with Java)

  • 1. Computer Vision Luigi De Russis Introduction to OpenCV
  • 2. 2 OpenC… what? OpenCV in brief Introduction to OpenCV 07/11/2013
  • 3. What is OpenCV? 3  Open source Computer Vision library BSD License  http://opencv.org     Originally developed by Intel Has more than 2500 optimized algorithms Supports a lot of different languages C, C++, Python, Java  but is written natively in C++   Cross platform  also available for Android and iOS Introduction to OpenCV 07/11/2013
  • 4. What it is used for? 4          Human-Computer Interaction (HCI) Object Identification Object Recognition Face Recognition Gesture Recognition Motion Tracking Image Processing Mobile Robotics … and so on Introduction to OpenCV 07/11/2013
  • 5. 5 Motivations - OpenCV Always ask “why?” Introduction to OpenCV 07/11/2013
  • 7. OpenCV: pros 7  Specificity  OpenCV was made for 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  Efficient  Matlab Introduction to OpenCV needs more system resources than OpenCV 07/11/2013
  • 8. OpenCV: cons 8  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 Introduction to OpenCV 07/11/2013
  • 9. OpenCV: pros (final) 9   Price (!) OpenCV Wrappers  SimpleCV,  Emgu CV, ruby-opencv… More similar to industry-level frameworks Introduction to OpenCV 07/11/2013
  • 10. 10 Motivation - Java When Java meets OpenCV Introduction to OpenCV 07/11/2013
  • 11. Some facts… 11  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 for adding Qt support  C++ learning curve is quite… steep  source: experiences from teaching this course in the last years Introduction to OpenCV 07/11/2013
  • 12. Some (other) facts… 12  OpenCV C++ APIs exists since OpenCV 1.0  It is possible, but not recommended, to “mix” different OpenCV version  Typically, it is a good way to get into trouble!  It is possible to use OpenCV C APIs together with C++ APIs  Typically Introduction to OpenCV it is a good way to get into trouble! 07/11/2013
  • 13. Some (other) facts… 13  OpenCV C++ API exists since OpenCV 1.0  It is possible, but not recommended, to “mix” different OpenCV version  Typically, it is a good way to get into trouble! Yeah, some students did it!  It is possible to use OpenCV C APIs together with C++ APIs  Typically Introduction to OpenCV it is a good way to get into trouble! 07/11/2013
  • 14. A better world is possible? 14  OpenCV provides also the Java APIs nothing to compile (on Windows)  they works on Android, also   Java 7 has a first-grade user interface not Swing, but JavaFX  http://www.oracle.com/technetwork/java/javafx    Almost everybody here should have some (basic) experience with Java Performance between the C++ APIs and the Java APIs are comparable Introduction to OpenCV 07/11/2013
  • 15. A better world is possible? 15  The OpenCV Java APIs are almost identical 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 change a bit  examples:  CV_RGB2GRAY (C++) becomes COLOR_RGB2GRAY (Java)  Point, Point2d, Point2f (C++) becomes 3 overloaded constructor of Point (Java) Introduction to OpenCV 07/11/2013
  • 16. A better world is possible? 16  Question:  is OpenCV with Java/JavaFX the “best” solution for every application? Introduction to OpenCV 07/11/2013
  • 17. A better world is possible? 17  Question:  is OpenCV with Java/JavaFX the “best” solution for every application?  Response:  No, obviously  Do you need a GUI? Go with JavaFX!  Do you have memory constraint? Go with C/C++! …  Please, no extremism! Introduction to OpenCV 07/11/2013
  • 18. 18 OpenCV meets Java Getting started with OpenCV and Java Introduction to OpenCV 07/11/2013
  • 19. Modules 19 OpenCV has a modular structure: the package includes several shared or static libraries  core   imgproc   basic structures and algorithms image processing algorithms (such as image filtering, geometrical image transformations, histograms, etc.) video  video analysis (such as motion estimation and object tracking) Introduction to OpenCV 07/11/2013
  • 20. Modules 20  highgui   calib3d   camera calibration and 3D reconstruction features2d   basic operation to read/write/encode images; in C, C++ and Python it provides also basic UI capabilities 2D features framework (feature detectors, descriptors, and descriptor matchers) objdetect  detection of objects and other items (e.g., faces, eyes, mugs, people, …) Introduction to OpenCV 07/11/2013
  • 21. Modules 21  ml  machine learning classes used for statistical classification, regression and clustering of data  gpu  GPU-accelerated  photo  computational  algorithms photography ccl  OpenCL-accelerated Introduction to OpenCV algorithms 07/11/2013
  • 22. Data Structures 22    We speak about Java API All the OpenCV classes and methods are placed into the org.opencv.* packages 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 in C++)  two data parts: matrix header (contains information about the matrix)  a pointer to the matrix containing the pixel values  Introduction to OpenCV 07/11/2013
  • 23. Data Structures 23  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 Introduction to OpenCV 07/11/2013
  • 24. Basic Image I/O 24  Highgui.imread  loads an image from file and return the corresponding Mat object Mat Highgui.imread(String filename, int flags)  Highui.imwrite  save an image on disk bool Highgui.imwrite(String filename, Mat img, MatOfInt params) Introduction to OpenCV 07/11/2013
  • 25. Basic Drawing Operations 25     Core.circle  draws a simple or filled circle with a given center and radius on a given image Core.line  draws a line between two point in the given image Core.ellipse  draws an ellipse outline, a filled ellipse, an elliptic arc, a filled ellipse sector, … Core.rectangle  draws a rectangle outline or a filled rectangle  note that negative thickness will fill the rectangle Introduction to OpenCV 07/11/2013
  • 26. Color Spaces 26  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 Introduction to OpenCV 07/11/2013
  • 27. 27 Let’s get practical! Getting started (without going crazy) Introduction to OpenCV 07/11/2013
  • 28. How can we use OpenCV? 28  LABINF:  already installed under Windows  version 2.4.6  Eclipse (Kepler) is the IDE  At home:  you can use whatever IDE you like  but we give full support only for Eclipse  Installation:  see the PDF document in the teaching portal Introduction to OpenCV 07/11/2013
  • 29. What if I got problems? 29  Small problems  drop me a line   luigi.derussis@polito.it Normal problems Problems with JavaFX and a gray scale image Awesome student to me Hi, […] I’m using “cvtColor(image, gray, COLOR_BGR2GRAY);” but it give this exception: […] Can you help me? come to office hours  every Wednesday, 9:00 - 11:00  LAB6, second floor of DAUIN  please send an e-mail beforehand   Regards, … Enormous problems pray?  no, seriously, we can schedule an extra “lesson”  Introduction to OpenCV 07/11/2013
  • 30. What if I got problems? 30 OpenCV installation  Small problems  drop me a line   luigi.derussis@polito.it Normal problems 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, … come to office hours  every Wednesday, 9:00 - 11:00  LAB6, second floor of DAUIN  please send an e-mail beforehand   Enormous problems pray?  no, seriously, we can schedule an extra “lesson”  Introduction to OpenCV 07/11/2013
  • 31. What if I got problems? 31  Small problems  drop me a line   luigi.derussis@polito.it Normal problems come to office hours  every Wednesday, 9:00 - 11:00  LAB6, second floor of DAUIN  please send an e-mail beforehand  Help with OpenCV 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?  Enormous problems Regards, … pray?  no, seriously, we can schedule an extra “lesson”  Introduction to OpenCV 07/11/2013
  • 32. An e-mail not to be sent! 32 Introduction to OpenCV 07/11/2013
  • 33. Useful Resources… 33  OpenCV Wiki   OpenCV Official Documentation   http://answers.opencv.org/questions/ OpenCV Javadocs   http://docs.opencv.org/ User Q&A forum   http://code.opencv.org/projects/opencv/wiki http://docs.opencv.org/java/ JavaFX Documentation  http://www.oracle.com/technetwork/java/javafx/document ation Introduction to OpenCV 07/11/2013
  • 34. 34 Demo Hour Put everything together Introduction to OpenCV 07/11/2013
  • 35. License 35   This work is licensed under the Creative Commons “AttributionNonCommercial-ShareAlike Unported (CC BY-NC-SA 3,0)” License. You are free:    Under the following conditions:     to Share - to copy, distribute and transmit the work to Remix - to adapt the work 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. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ Introduction to OpenCV 07/11/2013