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

Computer vision introduction
Computer vision  introduction Computer vision  introduction
Computer vision introduction Wael Badawy
 
"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
 
Object detection with deep learning
Object detection with deep learningObject detection with deep learning
Object detection with deep learningSushant Shrivastava
 
Machine learning in image processing
Machine learning in image processingMachine learning in image processing
Machine learning in image processingData Science Thailand
 
Handwritten digit recognition using image processing
Handwritten digit recognition using image processing Handwritten digit recognition using image processing
Handwritten digit recognition using image processing anita maharjan
 
Object detection
Object detectionObject detection
Object detectionSomesh Vyas
 
Deep learning based object detection
Deep learning based object detectionDeep learning based object detection
Deep learning based object detectionchettykulkarni
 
openCV with python
openCV with pythonopenCV with python
openCV with pythonWei-Wen Hsu
 
Deep learning for image video processing
Deep learning for image video processingDeep learning for image video processing
Deep learning for image video processingYu Huang
 
Lec14 multiview stereo
Lec14 multiview stereoLec14 multiview stereo
Lec14 multiview stereoBaliThorat1
 
Computer vision and Open CV
Computer vision and Open CVComputer vision and Open CV
Computer vision and Open CVChariza Pladin
 
Computer Vision - Real Time Face Recognition using Open CV and Python
Computer Vision - Real Time Face Recognition using Open CV and PythonComputer Vision - Real Time Face Recognition using Open CV and Python
Computer Vision - Real Time Face Recognition using Open CV and PythonAkash Satamkar
 
Object detection presentation
Object detection presentationObject detection presentation
Object detection presentationAshwinBicholiya
 
Image analysis using python
Image analysis using pythonImage analysis using python
Image analysis using pythonJerlyn Manohar
 

What's hot (20)

Computer vision introduction
Computer vision  introduction Computer vision  introduction
Computer vision introduction
 
"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...
 
Object detection with deep learning
Object detection with deep learningObject detection with deep learning
Object detection with deep learning
 
Machine learning in image processing
Machine learning in image processingMachine learning in image processing
Machine learning in image processing
 
face detection
face detectionface detection
face detection
 
Computer vision
Computer vision Computer vision
Computer vision
 
Image recognition
Image recognitionImage recognition
Image recognition
 
Handwritten digit recognition using image processing
Handwritten digit recognition using image processing Handwritten digit recognition using image processing
Handwritten digit recognition using image processing
 
Object detection
Object detectionObject detection
Object detection
 
Computer vision
Computer visionComputer vision
Computer vision
 
Object detection
Object detectionObject detection
Object detection
 
Deep learning based object detection
Deep learning based object detectionDeep learning based object detection
Deep learning based object detection
 
openCV with python
openCV with pythonopenCV with python
openCV with python
 
Deep learning for image video processing
Deep learning for image video processingDeep learning for image video processing
Deep learning for image video processing
 
Lec14 multiview stereo
Lec14 multiview stereoLec14 multiview stereo
Lec14 multiview stereo
 
Face Detection
Face DetectionFace Detection
Face Detection
 
Computer vision and Open CV
Computer vision and Open CVComputer vision and Open CV
Computer vision and Open CV
 
Computer Vision - Real Time Face Recognition using Open CV and Python
Computer Vision - Real Time Face Recognition using Open CV and PythonComputer Vision - Real Time Face Recognition using Open CV and Python
Computer Vision - Real Time Face Recognition using Open CV and Python
 
Object detection presentation
Object detection presentationObject detection presentation
Object detection presentation
 
Image analysis using python
Image analysis using pythonImage analysis using python
Image analysis using python
 

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

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
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.pdfOrbitshub
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
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...Martijn de Jong
 
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 2024Victor Rentea
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
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 2024The Digital Insurer
 
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 connectorsNanddeep Nachan
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 

Recently uploaded (20)

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
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
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [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...
 
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
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
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
 
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
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 

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: