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

"The OpenCV Open Source Computer Vision Library: What’s New and What’s Coming...
"The OpenCV Open Source Computer Vision Library: What’s New and What’s Coming..."The OpenCV Open Source Computer Vision Library: What’s New and What’s Coming...
"The OpenCV Open Source Computer Vision Library: What’s New and What’s Coming...Edge AI and Vision Alliance
 
OpenGL Introduction.
OpenGL Introduction.OpenGL Introduction.
OpenGL Introduction.Girish Ghate
 
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
 
Introduction to Generative Adversarial Networks (GANs)
Introduction to Generative Adversarial Networks (GANs)Introduction to Generative Adversarial Networks (GANs)
Introduction to Generative Adversarial Networks (GANs)Appsilon Data Science
 
ResNet basics (Deep Residual Network for Image Recognition)
ResNet basics (Deep Residual Network for Image Recognition)ResNet basics (Deep Residual Network for Image Recognition)
ResNet basics (Deep Residual Network for Image Recognition)Sanjay Saha
 
Introduction to CNN
Introduction to CNNIntroduction to CNN
Introduction to CNNShuai Zhang
 
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
 
Object Detection & Tracking
Object Detection & TrackingObject Detection & Tracking
Object Detection & TrackingAkshay Gujarathi
 
Generative Adversarial Networks
Generative Adversarial NetworksGenerative Adversarial Networks
Generative Adversarial NetworksMustafa Yagmur
 
Deep Learning in Computer Vision
Deep Learning in Computer VisionDeep Learning in Computer Vision
Deep Learning in Computer VisionSungjoon Choi
 
Convolutional neural network
Convolutional neural networkConvolutional neural network
Convolutional neural networkMojammilHusain
 
Introduction to the Artificial Intelligence and Computer Vision revolution
Introduction to the Artificial Intelligence and Computer Vision revolutionIntroduction to the Artificial Intelligence and Computer Vision revolution
Introduction to the Artificial Intelligence and Computer Vision revolutionDarian Frajberg
 
Image classification using cnn
Image classification using cnnImage classification using cnn
Image classification using cnnDebarko De
 
Convolution Neural Network (CNN)
Convolution Neural Network (CNN)Convolution Neural Network (CNN)
Convolution Neural Network (CNN)Suraj Aavula
 

What's hot (20)

"The OpenCV Open Source Computer Vision Library: What’s New and What’s Coming...
"The OpenCV Open Source Computer Vision Library: What’s New and What’s Coming..."The OpenCV Open Source Computer Vision Library: What’s New and What’s Coming...
"The OpenCV Open Source Computer Vision Library: What’s New and What’s Coming...
 
OpenGL Introduction.
OpenGL Introduction.OpenGL Introduction.
OpenGL Introduction.
 
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
 
Introduction to Generative Adversarial Networks (GANs)
Introduction to Generative Adversarial Networks (GANs)Introduction to Generative Adversarial Networks (GANs)
Introduction to Generative Adversarial Networks (GANs)
 
ResNet basics (Deep Residual Network for Image Recognition)
ResNet basics (Deep Residual Network for Image Recognition)ResNet basics (Deep Residual Network for Image Recognition)
ResNet basics (Deep Residual Network for Image Recognition)
 
Introduction to CNN
Introduction to CNNIntroduction to CNN
Introduction to CNN
 
U-Net (1).pptx
U-Net (1).pptxU-Net (1).pptx
U-Net (1).pptx
 
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
 
OpenCV
OpenCVOpenCV
OpenCV
 
Object Detection & Tracking
Object Detection & TrackingObject Detection & Tracking
Object Detection & Tracking
 
Generative Adversarial Networks
Generative Adversarial NetworksGenerative Adversarial Networks
Generative Adversarial Networks
 
Deep Learning in Computer Vision
Deep Learning in Computer VisionDeep Learning in Computer Vision
Deep Learning in Computer Vision
 
Mask R-CNN
Mask R-CNNMask R-CNN
Mask R-CNN
 
Object detection
Object detectionObject detection
Object detection
 
Convolutional neural network
Convolutional neural networkConvolutional neural network
Convolutional neural network
 
CG mini project
CG mini projectCG mini project
CG mini project
 
Introduction to the Artificial Intelligence and Computer Vision revolution
Introduction to the Artificial Intelligence and Computer Vision revolutionIntroduction to the Artificial Intelligence and Computer Vision revolution
Introduction to the Artificial Intelligence and Computer Vision revolution
 
Image classification using cnn
Image classification using cnnImage classification using cnn
Image classification using cnn
 
Convolution Neural Network (CNN)
Convolution Neural Network (CNN)Convolution Neural Network (CNN)
Convolution Neural Network (CNN)
 
Java applet
Java appletJava applet
Java applet
 

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)

OpenCV Workshop
OpenCV WorkshopOpenCV Workshop
OpenCV Workshop
 
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
 
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

#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 

Recently uploaded (20)

#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

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: