SlideShare a Scribd company logo
1 of 46
Computer Vision
Programming using Android
and Open CV
Vishwas Raval,
Computer Vision in brief
Computer Vision… what?
 Computer Vision is the process of using a
computer based algorithm to identify
patterns in the data of images
 Basic Steps:
 Process the image
 Use an algorithm to identify a pattern
 Present that pattern in a meaningful way
What is Computer Vision?
Image Processing
An “Image” and A “Frame”
 Both images and frames are
made up of individual pixels
organized in a 2 dimensional
array.
 For a color image, each pixel
can be anything from 8 to 32
bits wide.
 Most monochrome images use
8 bits per pixel.
 A frame is a single image in a
video sequence.
X
Y
pixel
“Feature” - A Fundamental
Concept in Computer Vision
Feature (fchr) n.
A prominent or distinctive aspect, quality, or characteristic: a feature of one’s
personality; a feature of the landscape. http://www.thefreedictionary.com/feature
 The concept of, “a feature of an object” is very
important for most computer vision algorithms.
 In an image or frame, a feature is a group of
pixels with some unique attribute.
corner points edge contrast motion
Some Basic “Building Blocks”
Algorithms in Computer Vision
 Detection
 Motion Detection—Finds groups of pixels (features) that
are in motion (change in position from one frame to the
next).
 Line Detection—Finds groups of pixels (features) that are
organized in straight lines, along edges.
 Face Detection—Finds groups of pixels organized in a
group that fits the template of a face.
 Tracking
 Optical Flow based tracking—A combination of algorithms
used to track moving objects in a video using features.
What is Image in Computer?
Digital Image- Representing
Image into digits
W
H
A
TISIT
A BEGINNERS GUIDE TOCOMPUTER VISION
W
H
A
TISIT
A BEGINNERS GUIDE TOCOMPUTER VISION
W
H
A
TISIT
For more precision – Using
floating values
Image Classification
Classification
Why is it challenging?
COMPUTER
VISION HAS
SURPRISING
APPLICATIONS
OpenCV in brief
OpenCV… what?
What is OpenCV?
 Open source Computer Vision library
BSD License
http://opencv.org
 Originally developed by Intel
 Has more than 2500 optimized
algorithms
 Supports a lot of different languages
C, C++, Python, Java but is written
natively in C++
 Cross platform
also available for Android and iOS
Open CV – At Glance
Capabilities
What it is used for?
 Human-Computer Interaction
(HCI)
 Object Recognition
 Face Recognition
 Gesture Recognition
 Motion Tracking
 Image Processing
 Mobile Robotics
 … and so on
Always ask
Motivations
Why OpenCV?
OpenCV: pros & cons
Specificity
OpenCV was made for image processing, Matlab
is quite generic
Processing Speed
30+ frames/second in real time image
processing with OpenCV. Around 4-5
frames/second in Matlab
Efficient
Matlab needs more system resources than
OpenCV
 Price (!)
OpenCV: pros & cons
 Easy of use
Matlab won hands down!
 Integrated Development Environment (IDE)
you can use Eclipse, Netbeans, Visual
Studio, Qt, XCode, Android Studio … even a
simple text editor for OpenCV
 Matlab has its own IDE
 Automatic memory management in OpenCV
OpenCV meets Android
Modules
OpenCV has a modular structure:
the package includes several shared or static libraries
core
basic structures and algorithms
imgproc
image processing algorithms (such as image
filtering, geometrical image transformations,
histograms, etc.)
video
video analysis (such as motion estimation and
object tracking)
Modules
highgui
basic operation to read/write/encode images; in C,
C++ and Python it provides also basic UI
capabilities
calib3d
camera calibration and 3D reconstruction
features2d
2D features framework (feature detectors,
descriptors, and descriptor matchers)
objdetect
detection of objects and other items (e.g., faces,
eyes, mugs, people, …)
Modules
 ml
machine learning classes used for statistical
classification, regression and clustering of
data
 gpu
GPU-accelerated algorithms
 photo
computational photography
 ccl
OpenCL-accelerated algorithms
Data Structures
 We speak about Java API
 All the OpenCV classes and methods are placed
into the org.opencv.* packages
 Mat: The primary image structure in OpenCV 2.x
overcomes the “old” IplImage/CvMat problem of
(OpenCV x/C API) automatic memory management
(more or less in C++) two data parts:
 matrix header (contains information about the matrix)
 a pointer to the matrix containing the pixel values
Data Structures
Point
2D point defined by x, y coordinates
 Point first = new Point(2, 3);
Size
2D size structure specify the size (width and
height) of an image or rectangle
Rect
2D rectangle object
Basic Image I/O
 Highgui.imread
loads an image from file and return the
corresponding Mat object
 Highui.imwrite save an image on disk
Basic Drawing Operations
 Core.circle
draws a simple or filled circle with a given center and radius
on a given image
 Core.line
draws a line between two point in the given image
 Core.ellipse
draws an ellipse outline, a filled ellipse, an elliptic arc, a
filled ellipse sector, …
 Core.rectangle
draws a rectangle outline or a filled rectangle note that
negative thickness will fill the rectangle
Color Spaces
 Imgproc.cvtColor
converts an input image from one color space to
another examples:
 Important! Images in OpenCV uses BGR instead
of RGB
 cvtColor(src, dest, Imgproc.COLOR_RGB2GRAY);
 cvtColor(src, dest, Imgproc.COLOR_HSV2BGR);
 cvtColor(src, dest, Imgproc.COLOR_RGB2BGR);
Getting Started…
Configuring Open CV in Android
Studio
1. Extract the downloaded zip file.
2. Open Android Studio and create a new project
with package of your choice.
3. Then select File ->New -> Import Module
4. You need to select the OpenCV SDK location.
Select OpenCV-android-sdk/sdk/java. Then
select Next and Finish. OpenCV sdk is imported
as a module.
Configuring Open CV in Android
Studio
But it may throw error. Lets see how to fix this.
5. In the project explorer change the project view
from Android to Project. Open Project ->
openCVLibrary -> build.gradle
6. Change
the compileSdkVersion, targetSdkVersion and
buildToolsVersion value to the latest version
you use. Then sync the project. The errors will be
gone.
Configuring Open CV in Android
Studio
7. Switch back to Android view in Project explorer.
Right click on the app module and select Open
Module Settings.
8. For the app module in the Dependencies tab, select
Add -> Module Dependency -> openCVLibrary
Add Native Library
1. Now we need to add native JNI libraries in our
project. These libraries should be added in
jniLibs directory. Create a new jniLibs directory
in app-> src -> main.
2. Open the extracted OpenCV SDK directory.
Switch to OpenCV-android-sdk/sdk/native/libs
directory.
Add Native Library
3. You will find directories for many CPU
architectures. Copy the required architecture
directory to the jniLibs directory. (for eg. Copy
x86_64 and armeabi-v7a because if your Android
emulator has x86_64 architecture and Phone has
armeabi-v7a architecture. Delete all files except
libopencv_java3.so. (Deleting is optional)
Demo
• See the demo given

More Related Content

Similar to OpenCV+Android.pptx

A Tutorial On Ip 2
A Tutorial On Ip 2A Tutorial On Ip 2
A Tutorial On Ip 2ankuredkie
 
502021435-12345678Minor-Project-Ppt.pptx
502021435-12345678Minor-Project-Ppt.pptx502021435-12345678Minor-Project-Ppt.pptx
502021435-12345678Minor-Project-Ppt.pptxshrey4922
 
Color Based Object Tracking with OpenCV A Survey
Color Based Object Tracking with OpenCV A SurveyColor Based Object Tracking with OpenCV A Survey
Color Based Object Tracking with OpenCV A SurveyYogeshIJTSRD
 
Law cost portable machine vision system
Law cost portable machine vision systemLaw cost portable machine vision system
Law cost portable machine vision systemSagarika Muthukumarana
 
Automatic License Plate Recognition using OpenCV
Automatic License Plate Recognition using OpenCVAutomatic License Plate Recognition using OpenCV
Automatic License Plate Recognition using OpenCVEditor IJCATR
 
Automatic License Plate Recognition using OpenCV
Automatic License Plate Recognition using OpenCV Automatic License Plate Recognition using OpenCV
Automatic License Plate Recognition using OpenCV Editor IJCATR
 
OpenCV (Open source computer vision)
OpenCV (Open source computer vision)OpenCV (Open source computer vision)
OpenCV (Open source computer vision)Chetan Allapur
 
16 OpenCV Functions to Start your Computer Vision journey.docx
16 OpenCV Functions to Start your Computer Vision journey.docx16 OpenCV Functions to Start your Computer Vision journey.docx
16 OpenCV Functions to Start your Computer Vision journey.docxssuser90e017
 
IEEE EED2021 AI use cases in Computer Vision
IEEE EED2021 AI use cases in Computer VisionIEEE EED2021 AI use cases in Computer Vision
IEEE EED2021 AI use cases in Computer VisionSAMeh Zaghloul
 
Law cost portable machine vision system
Law cost portable machine vision systemLaw cost portable machine vision system
Law cost portable machine vision systemSagarika Muthukumarana
 
Using Deep Learning for Computer Vision Applications
Using Deep Learning for Computer Vision ApplicationsUsing Deep Learning for Computer Vision Applications
Using Deep Learning for Computer Vision ApplicationsFarshid Pirahansiah
 
Computer Vision di Era Industri 4.0
Computer Vision di Era Industri 4.0Computer Vision di Era Industri 4.0
Computer Vision di Era Industri 4.0Achmad Solichin
 
IRJET- Object Detection in an Image using Convolutional Neural Network
IRJET- Object Detection in an Image using Convolutional Neural NetworkIRJET- Object Detection in an Image using Convolutional Neural Network
IRJET- Object Detection in an Image using Convolutional Neural NetworkIRJET Journal
 

Similar to OpenCV+Android.pptx (20)

A Tutorial On Ip 2
A Tutorial On Ip 2A Tutorial On Ip 2
A Tutorial On Ip 2
 
502021435-12345678Minor-Project-Ppt.pptx
502021435-12345678Minor-Project-Ppt.pptx502021435-12345678Minor-Project-Ppt.pptx
502021435-12345678Minor-Project-Ppt.pptx
 
Color Based Object Tracking with OpenCV A Survey
Color Based Object Tracking with OpenCV A SurveyColor Based Object Tracking with OpenCV A Survey
Color Based Object Tracking with OpenCV A Survey
 
Law cost portable machine vision system
Law cost portable machine vision systemLaw cost portable machine vision system
Law cost portable machine vision system
 
Automatic License Plate Recognition using OpenCV
Automatic License Plate Recognition using OpenCVAutomatic License Plate Recognition using OpenCV
Automatic License Plate Recognition using OpenCV
 
Automatic License Plate Recognition using OpenCV
Automatic License Plate Recognition using OpenCV Automatic License Plate Recognition using OpenCV
Automatic License Plate Recognition using OpenCV
 
Opencv
OpencvOpencv
Opencv
 
MAJOR PROJECT
MAJOR PROJECT MAJOR PROJECT
MAJOR PROJECT
 
OpenCV (Open source computer vision)
OpenCV (Open source computer vision)OpenCV (Open source computer vision)
OpenCV (Open source computer vision)
 
16 OpenCV Functions to Start your Computer Vision journey.docx
16 OpenCV Functions to Start your Computer Vision journey.docx16 OpenCV Functions to Start your Computer Vision journey.docx
16 OpenCV Functions to Start your Computer Vision journey.docx
 
Open Cv
Open CvOpen Cv
Open Cv
 
Computer Vision Introduction
Computer Vision IntroductionComputer Vision Introduction
Computer Vision Introduction
 
IEEE EED2021 AI use cases in Computer Vision
IEEE EED2021 AI use cases in Computer VisionIEEE EED2021 AI use cases in Computer Vision
IEEE EED2021 AI use cases in Computer Vision
 
ComputerVision.pptx
ComputerVision.pptxComputerVision.pptx
ComputerVision.pptx
 
Law cost portable machine vision system
Law cost portable machine vision systemLaw cost portable machine vision system
Law cost portable machine vision system
 
Using Deep Learning for Computer Vision Applications
Using Deep Learning for Computer Vision ApplicationsUsing Deep Learning for Computer Vision Applications
Using Deep Learning for Computer Vision Applications
 
Introduction to OpenCV
Introduction to OpenCVIntroduction to OpenCV
Introduction to OpenCV
 
Computer Vision di Era Industri 4.0
Computer Vision di Era Industri 4.0Computer Vision di Era Industri 4.0
Computer Vision di Era Industri 4.0
 
Facedetect
FacedetectFacedetect
Facedetect
 
IRJET- Object Detection in an Image using Convolutional Neural Network
IRJET- Object Detection in an Image using Convolutional Neural NetworkIRJET- Object Detection in an Image using Convolutional Neural Network
IRJET- Object Detection in an Image using Convolutional Neural Network
 

Recently uploaded

Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
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
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
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
 
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
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
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
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
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
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
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
 

Recently uploaded (20)

Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
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
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
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
 
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
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
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
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
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
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
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
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 

OpenCV+Android.pptx

  • 1. Computer Vision Programming using Android and Open CV Vishwas Raval,
  • 2. Computer Vision in brief Computer Vision… what?
  • 3.  Computer Vision is the process of using a computer based algorithm to identify patterns in the data of images  Basic Steps:  Process the image  Use an algorithm to identify a pattern  Present that pattern in a meaningful way What is Computer Vision?
  • 5. An “Image” and A “Frame”  Both images and frames are made up of individual pixels organized in a 2 dimensional array.  For a color image, each pixel can be anything from 8 to 32 bits wide.  Most monochrome images use 8 bits per pixel.  A frame is a single image in a video sequence. X Y pixel
  • 6. “Feature” - A Fundamental Concept in Computer Vision Feature (fchr) n. A prominent or distinctive aspect, quality, or characteristic: a feature of one’s personality; a feature of the landscape. http://www.thefreedictionary.com/feature  The concept of, “a feature of an object” is very important for most computer vision algorithms.  In an image or frame, a feature is a group of pixels with some unique attribute. corner points edge contrast motion
  • 7. Some Basic “Building Blocks” Algorithms in Computer Vision  Detection  Motion Detection—Finds groups of pixels (features) that are in motion (change in position from one frame to the next).  Line Detection—Finds groups of pixels (features) that are organized in straight lines, along edges.  Face Detection—Finds groups of pixels organized in a group that fits the template of a face.  Tracking  Optical Flow based tracking—A combination of algorithms used to track moving objects in a video using features.
  • 8. What is Image in Computer?
  • 11. A BEGINNERS GUIDE TOCOMPUTER VISION W H A TISIT
  • 12. A BEGINNERS GUIDE TOCOMPUTER VISION W H A TISIT
  • 13. For more precision – Using floating values
  • 15. Why is it challenging?
  • 17.
  • 18.
  • 20. What is OpenCV?  Open source Computer Vision library BSD License http://opencv.org  Originally developed by Intel  Has more than 2500 optimized algorithms  Supports a lot of different languages C, C++, Python, Java but is written natively in C++  Cross platform also available for Android and iOS
  • 21. Open CV – At Glance
  • 23. What it is used for?  Human-Computer Interaction (HCI)  Object Recognition  Face Recognition  Gesture Recognition  Motion Tracking  Image Processing  Mobile Robotics  … and so on
  • 26. OpenCV: pros & cons Specificity OpenCV was made for image processing, Matlab is quite generic Processing Speed 30+ frames/second in real time image processing with OpenCV. Around 4-5 frames/second in Matlab Efficient Matlab needs more system resources than OpenCV  Price (!)
  • 27. OpenCV: pros & cons  Easy of use Matlab won hands down!  Integrated Development Environment (IDE) you can use Eclipse, Netbeans, Visual Studio, Qt, XCode, Android Studio … even a simple text editor for OpenCV  Matlab has its own IDE  Automatic memory management in OpenCV
  • 29. Modules OpenCV has a modular structure: the package includes several shared or static libraries core basic structures and algorithms imgproc image processing algorithms (such as image filtering, geometrical image transformations, histograms, etc.) video video analysis (such as motion estimation and object tracking)
  • 30. Modules highgui basic operation to read/write/encode images; in C, C++ and Python it provides also basic UI capabilities calib3d camera calibration and 3D reconstruction features2d 2D features framework (feature detectors, descriptors, and descriptor matchers) objdetect detection of objects and other items (e.g., faces, eyes, mugs, people, …)
  • 31. Modules  ml machine learning classes used for statistical classification, regression and clustering of data  gpu GPU-accelerated algorithms  photo computational photography  ccl OpenCL-accelerated algorithms
  • 32. Data Structures  We speak about Java API  All the OpenCV classes and methods are placed into the org.opencv.* packages  Mat: The primary image structure in OpenCV 2.x overcomes the “old” IplImage/CvMat problem of (OpenCV x/C API) automatic memory management (more or less in C++) two data parts:  matrix header (contains information about the matrix)  a pointer to the matrix containing the pixel values
  • 33. Data Structures Point 2D point defined by x, y coordinates  Point first = new Point(2, 3); Size 2D size structure specify the size (width and height) of an image or rectangle Rect 2D rectangle object
  • 34. Basic Image I/O  Highgui.imread loads an image from file and return the corresponding Mat object  Highui.imwrite save an image on disk
  • 35. Basic Drawing Operations  Core.circle draws a simple or filled circle with a given center and radius on a given image  Core.line draws a line between two point in the given image  Core.ellipse draws an ellipse outline, a filled ellipse, an elliptic arc, a filled ellipse sector, …  Core.rectangle draws a rectangle outline or a filled rectangle note that negative thickness will fill the rectangle
  • 36. Color Spaces  Imgproc.cvtColor converts an input image from one color space to another examples:  Important! Images in OpenCV uses BGR instead of RGB  cvtColor(src, dest, Imgproc.COLOR_RGB2GRAY);  cvtColor(src, dest, Imgproc.COLOR_HSV2BGR);  cvtColor(src, dest, Imgproc.COLOR_RGB2BGR);
  • 38. Configuring Open CV in Android Studio 1. Extract the downloaded zip file. 2. Open Android Studio and create a new project with package of your choice. 3. Then select File ->New -> Import Module 4. You need to select the OpenCV SDK location. Select OpenCV-android-sdk/sdk/java. Then select Next and Finish. OpenCV sdk is imported as a module.
  • 39.
  • 40. Configuring Open CV in Android Studio But it may throw error. Lets see how to fix this. 5. In the project explorer change the project view from Android to Project. Open Project -> openCVLibrary -> build.gradle 6. Change the compileSdkVersion, targetSdkVersion and buildToolsVersion value to the latest version you use. Then sync the project. The errors will be gone.
  • 41.
  • 42. Configuring Open CV in Android Studio 7. Switch back to Android view in Project explorer. Right click on the app module and select Open Module Settings. 8. For the app module in the Dependencies tab, select Add -> Module Dependency -> openCVLibrary
  • 43.
  • 44. Add Native Library 1. Now we need to add native JNI libraries in our project. These libraries should be added in jniLibs directory. Create a new jniLibs directory in app-> src -> main. 2. Open the extracted OpenCV SDK directory. Switch to OpenCV-android-sdk/sdk/native/libs directory.
  • 45. Add Native Library 3. You will find directories for many CPU architectures. Copy the required architecture directory to the jniLibs directory. (for eg. Copy x86_64 and armeabi-v7a because if your Android emulator has x86_64 architecture and Phone has armeabi-v7a architecture. Delete all files except libopencv_java3.so. (Deleting is optional)
  • 46. Demo • See the demo given