SlideShare a Scribd company logo
1 of 32
Download to read offline
(Open Source Computer Vision)
Outline
●

Overview and practical issues.

●

A selection of OpenCV functionality:
–
–

Object classification and tracking

–

●

Image enhancement
Face detection and recognition

Conclusion and further resources.
Overview: Capabilities
Overview: License
●

BSD Licensed (free and open source)

●

May be used in commercial software.

●

No requirement to publish the source!

●

Must acknowledge OpenCV was used in the
documentation by including its copyright notice.
Note: There is a C#/.NET wrapper for OpenCV
called “Emgu CV” that may be commercially
licensed.
Overview: Patents

●

Note: A couple of algorithms (SIFT and SURF)
that are implemented are patented.
–

You can't accidentally use them because they are in
a separate module called “nonfree”.
Overview: Users

●

Stitching street-view images together,

●

Detecting intrusions in surveillance video in Israel

●

Detection of swimming pool drowning accidents in
Europe
Overview: Environment
Overview: Environment

Primary API
is C++

Leverages
ARM NEON
Overview: Installation
●

Ubuntu VM:
–

●

sudo apt-get install libopencv-dev

Windows:
–

Download latest version from http://opencv.org/
For Python:
●
●
●

Also install Python from http://www.python.org/
Install numpy module
Copy the “cv2” module from OpenCV to
C:Python27Libsite-packages
Overview: Hello World
Makefile
CC=g++
CFLAGS+=-std=c++0x `pkg-config
opencv --cflags`
LDFLAGS+=`pkg-config opencv
--libs`
PROG=hello
OBJS=$(PROG).o
.PHONY: all clean
$(PROG): $(OBJS)
$(CC) -o $(PROG).out $
(OBJS) $(LDFLAGS)

hello.cpp
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
int main()
{
cv::Mat image = cv::imread("lena.bmp");
if (image.empty())
{
std::cerr << "Could not load image";
return 1;
}

%.o: %.cpp
$(CC) -c $(CFLAGS) $<
all: $(PROG)
clean:
rm -f $(OBJS) $(PROG)

}

cv::namedWindow("Image");
cv::imshow("Image", image);
cv::waitKey();
return 0;
Overview: Hello World
Makefile
CC=g++
CFLAGS+=-std=c++0x `pkg-config
opencv --cflags`
LDFLAGS+=`pkg-config opencv
--libs`
PROG=hello
OBJS=$(PROG).o
.PHONY: all clean
$(PROG): $(OBJS)
$(CC) -o $(PROG).out $
(OBJS) $(LDFLAGS)

hello.cpp
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
int main()
{
cv::Mat image = cv::imread("lena.bmp");
if (image.empty())
{
std::cerr << "Could not load image";
return 1;
}

%.o: %.cpp
$(CC) -c $(CFLAGS) $<
all: $(PROG)
clean:
rm -f $(OBJS) $(PROG)

}

cv::namedWindow("Image");
cv::imshow("Image", image);
cv::waitKey();
return 0;
Overview: Hello World
hello.cpp

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
int main()
{
cv::Mat image = cv::imread("lena.bmp");
if (image.empty())
{
std::cerr << "Could not load image";
return 1;
}

}

cv::namedWindow("Image");
cv::imshow("Image", image);
cv::waitKey();
return 0;
Overview: Hello World
hello.cpp

#include
#include
#include
#include

<opencv2/core/core.hpp>
<opencv2/imgproc/imgproc.hpp>
<opencv2/highgui/highgui.hpp>
<iostream>

int main()
{
cv::Mat image = cv::imread("lena.bmp");
if (image.empty())
{
std::cerr << "Could not load image";
return 1;
}
cv::blur(image, image, cv::Size(10, 10));

}

cv::namedWindow("Image");
cv::imshow("Image", image);
cv::waitKey();
return 0;

Add a filter to blur
the image before
displaying it.
Overview: Hello World
hello.cpp

#include
#include
#include
#include

<opencv2/core/core.hpp>
<opencv2/imgproc/imgproc.hpp>
<opencv2/highgui/highgui.hpp>
<iostream>

int main()
{
cv::Mat image = cv::imread("lena.bmp");
if (image.empty())
{
std::cerr << "Could not load image";
return 1;
}
cv::blur(image, image, cv::Size(10, 10));

}

cv::namedWindow("Image");
cv::imshow("Image", image);
cv::waitKey();
return 0;
Python: Display an image file
import cv2
image = cv2.imread("lena.bmp");
if image.empty():
print "Could not load image"
exit(1)
cv2.namedWindow("Image")
cv2.imshow("Image", image)
cv2.waitKey()

Similar structure
and naming as C++
version means
Python is good for
prototyping.
Video from IP camera w/ RTSP!
#include <opencv/cxcore.h>
#include <opencv/highgui.h>
int main(int argc, char* argv[])
{
cv::Ptr<CvCapture> capture = cvCaptureFromFile(
"rtsp://admin:admin@10.10.32.33/video");
cv::namedWindow("Frame");
for (;;)
{
cv::Mat frame = cvQueryFrame(capture);
cv::imshow("Frame", frame);
if (cv::waitKey(1) >= 0)
break;
}
return 0;
}

Network comm.,
RTSP protocol, etc.
is all handled for you
so all you have to do
is process each
frame as an image
(a cv::Mat object).
A Selection of Functionality
●

Image enhancement
–

●

Noise reduction, local contrast enhancement

Object classification and tracking
–
–

●

Track the paths that objects take in a scene
Differentiating between cars and trucks

Face detection and recognition
–

Identify faces seen in images or video.
Image Enhancement
Many many algorithms. Here are a few:
●

●

●

Deconvolution – used to reduce focus blur or
motion blur where the motion is known.
Unsharp masking – increases sharpness and
local contrast (like WDR)
Histogram equalization – stretches contrast
and somewhat corrects for over- or underexposure.
Image Enhancement: Demo!
●

Deconvolution – Reducing motion blur below
where the motion is known.
Image Enhancement: Demo!
●

Deconvolution – Can also be used for poor
camera focus, but the parameters of the blur
must be estimated in advance.
Image Enhancement: Demo!
●

Deconvolution – Can also be used for poor
camera focus, but the parameters of the blur
must be estimated in advance.

Generated using OpenCV example:

/opencv/samples/python2/deconvolution.py
Image Enhancement
●

Histogram equalization: equalizeHist(img,

out)
Image Enhancement
●

Histogram equalization: equalizeHist(img,

Increases the
range of intensities
in an image, thereby
increasing contrast.

out)
Object detection and tracking
●

Foreground/background segmentation –
identify objects moving in a scene.
–

●

Histogram backprojection – identify objects by
their colour (even if they're not moving).
–

●

cv::BackgroundSubtractorMOG2

cv::calcBackProject()

Camshift tracking – track objects by their colour.
–

cv::CamShift
Face Detection and Recognition
Face detection and recognition
●

Detection:
–
–

●

Haar cascade – detect faces by identifying
adjacent light and dark regions.
cv::CascadeClassifier

Recognition:
–

Eigenfaces classifier – for facial recognition

–

cv::FaceRecognizer
Face detection: C++
cv::CascadeClassifier profileFaceCascade;
profileFaceCascade.load("haarcascade_profileface.xml");
std::vector<cv::Rect> faceRects;
profileFaceCascade.detectMultiScale(image, faceRects);
cv::Mat foundFacesImage = image.clone();
for (std::vector<cv::Rect>::const_iterator rect =
faceRects.begin(); rect != faceRects.end(); ++ rect)
{
cv::rectangle(foundFacesImage, *rect,
cv::Scalar(0, 0, 255), 3);
}
cv::namedWindow("Faces");
cv::imshow("Faces", foundFacesImage);
cv::waitKey();
Face detection: C++
cv::CascadeClassifier profileFaceCascade;
profileFaceCascade.load("haarcascade_profileface.xml");
std::vector<cv::Rect> faceRects;
profileFaceCascade.detectMultiScale(image, faceRects); with
OpenCV comes

other classifier XML
cv::Mat foundFacesImage = image.clone();
files for detecting other
for (std::vector<cv::Rect>::const_iterator rect (e.g eyes,
things =
faceRects.begin(); rect != faceRects.end(); ++ rect)
glasses, profile faces)
{
}

cv::rectangle(foundFacesImage, *rect,
cv::Scalar(0, 0, 255), 3);

cv::namedWindow("Faces");
cv::imshow("Faces", foundFacesImage);
cv::waitKey();
Face detection
●

Can be defeated with makeup...
Face detection
●

... or with special glasses containing IR LEDs.
Conclusion
●

●
●

●

OpenCV is for image/video processing and
computer vision.
Free and open source (BSD licensed)
Cross-platform and actively developed (also
downloaded over 3 million times)!
This presentation covered just a few of the over
2,000 algorithms available in OpenCV.
More Information
●

Official Page: http://opencv.org

●

Tutorials: http://docs.opencv.org/doc/tutorials/tutorials.html

●

Books:

More Related Content

What's hot

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
 
Introduction to object detection
Introduction to object detectionIntroduction to object detection
Introduction to object detectionBrodmann17
 
Image processing on matlab presentation
Image processing on matlab presentationImage processing on matlab presentation
Image processing on matlab presentationNaatchammai Ramanathan
 
Image Processing with OpenCV
Image Processing with OpenCVImage Processing with OpenCV
Image Processing with OpenCVdebayanin
 
Object Detection & Tracking
Object Detection & TrackingObject Detection & Tracking
Object Detection & TrackingAkshay Gujarathi
 
Basics of Object Oriented Programming in Python
Basics of Object Oriented Programming in PythonBasics of Object Oriented Programming in Python
Basics of Object Oriented Programming in PythonSujith Kumar
 
Facial expression recognition projc 2 (3) (1)
Facial expression recognition projc 2 (3) (1)Facial expression recognition projc 2 (3) (1)
Facial expression recognition projc 2 (3) (1)AbhiAchalla
 
Computer vision and face recognition using python
Computer vision and face recognition using pythonComputer vision and face recognition using python
Computer vision and face recognition using pythonRatnakar Pandey
 
Open Cv – An Introduction To The Vision
Open Cv – An Introduction To The VisionOpen Cv – An Introduction To The Vision
Open Cv – An Introduction To The VisionHemanth Haridas
 
Deep learning based object detection basics
Deep learning based object detection basicsDeep learning based object detection basics
Deep learning based object detection basicsBrodmann17
 
Advance OOP concepts in Python
Advance OOP concepts in PythonAdvance OOP concepts in Python
Advance OOP concepts in PythonSujith Kumar
 

What's hot (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
 
Introduction to object detection
Introduction to object detectionIntroduction to object detection
Introduction to object detection
 
Edge detection
Edge detectionEdge detection
Edge detection
 
OpenCV Workshop
OpenCV WorkshopOpenCV Workshop
OpenCV Workshop
 
Image processing on matlab presentation
Image processing on matlab presentationImage processing on matlab presentation
Image processing on matlab presentation
 
Image Processing with OpenCV
Image Processing with OpenCVImage Processing with OpenCV
Image Processing with OpenCV
 
Object Detection & Tracking
Object Detection & TrackingObject Detection & Tracking
Object Detection & Tracking
 
Color detection
Color detectionColor detection
Color detection
 
Line Detection
Line DetectionLine Detection
Line Detection
 
Basics of Object Oriented Programming in Python
Basics of Object Oriented Programming in PythonBasics of Object Oriented Programming in Python
Basics of Object Oriented Programming in Python
 
Kotlin
KotlinKotlin
Kotlin
 
Facial expression recognition projc 2 (3) (1)
Facial expression recognition projc 2 (3) (1)Facial expression recognition projc 2 (3) (1)
Facial expression recognition projc 2 (3) (1)
 
Computer vision and face recognition using python
Computer vision and face recognition using pythonComputer vision and face recognition using python
Computer vision and face recognition using python
 
Open Cv – An Introduction To The Vision
Open Cv – An Introduction To The VisionOpen Cv – An Introduction To The Vision
Open Cv – An Introduction To The Vision
 
Deep learning based object detection basics
Deep learning based object detection basicsDeep learning based object detection basics
Deep learning based object detection basics
 
Object oriented programming in python
Object oriented programming in pythonObject oriented programming in python
Object oriented programming in python
 
Advance OOP concepts in Python
Advance OOP concepts in PythonAdvance OOP concepts in Python
Advance OOP concepts in Python
 
Python Open CV
Python Open CVPython Open CV
Python Open CV
 
Shaders in Unity
Shaders in UnityShaders in Unity
Shaders in Unity
 
Image recognition
Image recognitionImage recognition
Image recognition
 

Similar to OpenCV Introduction

Open Cv 2005 Q4 Tutorial
Open Cv 2005 Q4 TutorialOpen Cv 2005 Q4 Tutorial
Open Cv 2005 Q4 Tutorialantiw
 
OpenCV (Open source computer vision)
OpenCV (Open source computer vision)OpenCV (Open source computer vision)
OpenCV (Open source computer vision)Chetan Allapur
 
OpenCV @ Droidcon 2012
OpenCV @ Droidcon 2012OpenCV @ Droidcon 2012
OpenCV @ Droidcon 2012Wingston
 
"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
 
20110220 computer vision_eruhimov_lecture02
20110220 computer vision_eruhimov_lecture0220110220 computer vision_eruhimov_lecture02
20110220 computer vision_eruhimov_lecture02Computer Science Club
 
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
 
Object detection
Object detectionObject detection
Object detectionSomesh Vyas
 
502021435-12345678Minor-Project-Ppt.pptx
502021435-12345678Minor-Project-Ppt.pptx502021435-12345678Minor-Project-Ppt.pptx
502021435-12345678Minor-Project-Ppt.pptxshrey4922
 
DevOps Workflow: A Tutorial on Linux Containers
DevOps Workflow: A Tutorial on Linux ContainersDevOps Workflow: A Tutorial on Linux Containers
DevOps Workflow: A Tutorial on Linux Containersinside-BigData.com
 
Serverless Container with Source2Image
Serverless Container with Source2ImageServerless Container with Source2Image
Serverless Container with Source2ImageQAware GmbH
 
Serverless containers … with source-to-image
Serverless containers  … with source-to-imageServerless containers  … with source-to-image
Serverless containers … with source-to-imageJosef Adersberger
 
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
 
426 lecture 4: AR Developer Tools
426 lecture 4: AR Developer Tools426 lecture 4: AR Developer Tools
426 lecture 4: AR Developer ToolsMark Billinghurst
 
Eye ball cursor movement using opencv
Eye ball cursor movement using opencvEye ball cursor movement using opencv
Eye ball cursor movement using opencvVenkat Projects
 
PVS-Studio in the Clouds: CircleCI
PVS-Studio in the Clouds: CircleCIPVS-Studio in the Clouds: CircleCI
PVS-Studio in the Clouds: CircleCIAndrey Karpov
 

Similar to OpenCV Introduction (20)

Open Cv 2005 Q4 Tutorial
Open Cv 2005 Q4 TutorialOpen Cv 2005 Q4 Tutorial
Open Cv 2005 Q4 Tutorial
 
OpenCV (Open source computer vision)
OpenCV (Open source computer vision)OpenCV (Open source computer vision)
OpenCV (Open source computer vision)
 
OpenCV+Android.pptx
OpenCV+Android.pptxOpenCV+Android.pptx
OpenCV+Android.pptx
 
Facedetect
FacedetectFacedetect
Facedetect
 
OpenCV @ Droidcon 2012
OpenCV @ Droidcon 2012OpenCV @ Droidcon 2012
OpenCV @ Droidcon 2012
 
"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...
 
20110220 computer vision_eruhimov_lecture02
20110220 computer vision_eruhimov_lecture0220110220 computer vision_eruhimov_lecture02
20110220 computer vision_eruhimov_lecture02
 
Surveillance on slam technology
Surveillance on slam technologySurveillance on slam technology
Surveillance on slam technology
 
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
 
Object detection
Object detectionObject detection
Object detection
 
502021435-12345678Minor-Project-Ppt.pptx
502021435-12345678Minor-Project-Ppt.pptx502021435-12345678Minor-Project-Ppt.pptx
502021435-12345678Minor-Project-Ppt.pptx
 
Opencv
OpencvOpencv
Opencv
 
DevOps Workflow: A Tutorial on Linux Containers
DevOps Workflow: A Tutorial on Linux ContainersDevOps Workflow: A Tutorial on Linux Containers
DevOps Workflow: A Tutorial on Linux Containers
 
Serverless Container with Source2Image
Serverless Container with Source2ImageServerless Container with Source2Image
Serverless Container with Source2Image
 
Serverless containers … with source-to-image
Serverless containers  … with source-to-imageServerless containers  … with source-to-image
Serverless containers … with source-to-image
 
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)
 
Computer Vision Introduction
Computer Vision IntroductionComputer Vision Introduction
Computer Vision Introduction
 
426 lecture 4: AR Developer Tools
426 lecture 4: AR Developer Tools426 lecture 4: AR Developer Tools
426 lecture 4: AR Developer Tools
 
Eye ball cursor movement using opencv
Eye ball cursor movement using opencvEye ball cursor movement using opencv
Eye ball cursor movement using opencv
 
PVS-Studio in the Clouds: CircleCI
PVS-Studio in the Clouds: CircleCIPVS-Studio in the Clouds: CircleCI
PVS-Studio in the Clouds: CircleCI
 

Recently uploaded

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
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
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
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
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
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 

Recently uploaded (20)

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
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
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
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
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
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 

OpenCV Introduction

  • 2. Outline ● Overview and practical issues. ● A selection of OpenCV functionality: – – Object classification and tracking – ● Image enhancement Face detection and recognition Conclusion and further resources.
  • 4. Overview: License ● BSD Licensed (free and open source) ● May be used in commercial software. ● No requirement to publish the source! ● Must acknowledge OpenCV was used in the documentation by including its copyright notice. Note: There is a C#/.NET wrapper for OpenCV called “Emgu CV” that may be commercially licensed.
  • 5. Overview: Patents ● Note: A couple of algorithms (SIFT and SURF) that are implemented are patented. – You can't accidentally use them because they are in a separate module called “nonfree”.
  • 6. Overview: Users ● Stitching street-view images together, ● Detecting intrusions in surveillance video in Israel ● Detection of swimming pool drowning accidents in Europe
  • 8. Overview: Environment Primary API is C++ Leverages ARM NEON
  • 9. Overview: Installation ● Ubuntu VM: – ● sudo apt-get install libopencv-dev Windows: – Download latest version from http://opencv.org/ For Python: ● ● ● Also install Python from http://www.python.org/ Install numpy module Copy the “cv2” module from OpenCV to C:Python27Libsite-packages
  • 10. Overview: Hello World Makefile CC=g++ CFLAGS+=-std=c++0x `pkg-config opencv --cflags` LDFLAGS+=`pkg-config opencv --libs` PROG=hello OBJS=$(PROG).o .PHONY: all clean $(PROG): $(OBJS) $(CC) -o $(PROG).out $ (OBJS) $(LDFLAGS) hello.cpp #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <iostream> int main() { cv::Mat image = cv::imread("lena.bmp"); if (image.empty()) { std::cerr << "Could not load image"; return 1; } %.o: %.cpp $(CC) -c $(CFLAGS) $< all: $(PROG) clean: rm -f $(OBJS) $(PROG) } cv::namedWindow("Image"); cv::imshow("Image", image); cv::waitKey(); return 0;
  • 11. Overview: Hello World Makefile CC=g++ CFLAGS+=-std=c++0x `pkg-config opencv --cflags` LDFLAGS+=`pkg-config opencv --libs` PROG=hello OBJS=$(PROG).o .PHONY: all clean $(PROG): $(OBJS) $(CC) -o $(PROG).out $ (OBJS) $(LDFLAGS) hello.cpp #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <iostream> int main() { cv::Mat image = cv::imread("lena.bmp"); if (image.empty()) { std::cerr << "Could not load image"; return 1; } %.o: %.cpp $(CC) -c $(CFLAGS) $< all: $(PROG) clean: rm -f $(OBJS) $(PROG) } cv::namedWindow("Image"); cv::imshow("Image", image); cv::waitKey(); return 0;
  • 12. Overview: Hello World hello.cpp #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <iostream> int main() { cv::Mat image = cv::imread("lena.bmp"); if (image.empty()) { std::cerr << "Could not load image"; return 1; } } cv::namedWindow("Image"); cv::imshow("Image", image); cv::waitKey(); return 0;
  • 13. Overview: Hello World hello.cpp #include #include #include #include <opencv2/core/core.hpp> <opencv2/imgproc/imgproc.hpp> <opencv2/highgui/highgui.hpp> <iostream> int main() { cv::Mat image = cv::imread("lena.bmp"); if (image.empty()) { std::cerr << "Could not load image"; return 1; } cv::blur(image, image, cv::Size(10, 10)); } cv::namedWindow("Image"); cv::imshow("Image", image); cv::waitKey(); return 0; Add a filter to blur the image before displaying it.
  • 14. Overview: Hello World hello.cpp #include #include #include #include <opencv2/core/core.hpp> <opencv2/imgproc/imgproc.hpp> <opencv2/highgui/highgui.hpp> <iostream> int main() { cv::Mat image = cv::imread("lena.bmp"); if (image.empty()) { std::cerr << "Could not load image"; return 1; } cv::blur(image, image, cv::Size(10, 10)); } cv::namedWindow("Image"); cv::imshow("Image", image); cv::waitKey(); return 0;
  • 15. Python: Display an image file import cv2 image = cv2.imread("lena.bmp"); if image.empty(): print "Could not load image" exit(1) cv2.namedWindow("Image") cv2.imshow("Image", image) cv2.waitKey() Similar structure and naming as C++ version means Python is good for prototyping.
  • 16. Video from IP camera w/ RTSP! #include <opencv/cxcore.h> #include <opencv/highgui.h> int main(int argc, char* argv[]) { cv::Ptr<CvCapture> capture = cvCaptureFromFile( "rtsp://admin:admin@10.10.32.33/video"); cv::namedWindow("Frame"); for (;;) { cv::Mat frame = cvQueryFrame(capture); cv::imshow("Frame", frame); if (cv::waitKey(1) >= 0) break; } return 0; } Network comm., RTSP protocol, etc. is all handled for you so all you have to do is process each frame as an image (a cv::Mat object).
  • 17. A Selection of Functionality ● Image enhancement – ● Noise reduction, local contrast enhancement Object classification and tracking – – ● Track the paths that objects take in a scene Differentiating between cars and trucks Face detection and recognition – Identify faces seen in images or video.
  • 18. Image Enhancement Many many algorithms. Here are a few: ● ● ● Deconvolution – used to reduce focus blur or motion blur where the motion is known. Unsharp masking – increases sharpness and local contrast (like WDR) Histogram equalization – stretches contrast and somewhat corrects for over- or underexposure.
  • 19. Image Enhancement: Demo! ● Deconvolution – Reducing motion blur below where the motion is known.
  • 20. Image Enhancement: Demo! ● Deconvolution – Can also be used for poor camera focus, but the parameters of the blur must be estimated in advance.
  • 21. Image Enhancement: Demo! ● Deconvolution – Can also be used for poor camera focus, but the parameters of the blur must be estimated in advance. Generated using OpenCV example: /opencv/samples/python2/deconvolution.py
  • 23. Image Enhancement ● Histogram equalization: equalizeHist(img, Increases the range of intensities in an image, thereby increasing contrast. out)
  • 24. Object detection and tracking ● Foreground/background segmentation – identify objects moving in a scene. – ● Histogram backprojection – identify objects by their colour (even if they're not moving). – ● cv::BackgroundSubtractorMOG2 cv::calcBackProject() Camshift tracking – track objects by their colour. – cv::CamShift
  • 25. Face Detection and Recognition
  • 26. Face detection and recognition ● Detection: – – ● Haar cascade – detect faces by identifying adjacent light and dark regions. cv::CascadeClassifier Recognition: – Eigenfaces classifier – for facial recognition – cv::FaceRecognizer
  • 27. Face detection: C++ cv::CascadeClassifier profileFaceCascade; profileFaceCascade.load("haarcascade_profileface.xml"); std::vector<cv::Rect> faceRects; profileFaceCascade.detectMultiScale(image, faceRects); cv::Mat foundFacesImage = image.clone(); for (std::vector<cv::Rect>::const_iterator rect = faceRects.begin(); rect != faceRects.end(); ++ rect) { cv::rectangle(foundFacesImage, *rect, cv::Scalar(0, 0, 255), 3); } cv::namedWindow("Faces"); cv::imshow("Faces", foundFacesImage); cv::waitKey();
  • 28. Face detection: C++ cv::CascadeClassifier profileFaceCascade; profileFaceCascade.load("haarcascade_profileface.xml"); std::vector<cv::Rect> faceRects; profileFaceCascade.detectMultiScale(image, faceRects); with OpenCV comes other classifier XML cv::Mat foundFacesImage = image.clone(); files for detecting other for (std::vector<cv::Rect>::const_iterator rect (e.g eyes, things = faceRects.begin(); rect != faceRects.end(); ++ rect) glasses, profile faces) { } cv::rectangle(foundFacesImage, *rect, cv::Scalar(0, 0, 255), 3); cv::namedWindow("Faces"); cv::imshow("Faces", foundFacesImage); cv::waitKey();
  • 29. Face detection ● Can be defeated with makeup...
  • 30. Face detection ● ... or with special glasses containing IR LEDs.
  • 31. Conclusion ● ● ● ● OpenCV is for image/video processing and computer vision. Free and open source (BSD licensed) Cross-platform and actively developed (also downloaded over 3 million times)! This presentation covered just a few of the over 2,000 algorithms available in OpenCV.
  • 32. More Information ● Official Page: http://opencv.org ● Tutorials: http://docs.opencv.org/doc/tutorials/tutorials.html ● Books: