SlideShare a Scribd company logo
1 of 19
OpenCV
      Image
      Processing
          on
      Android
      Devices

  Wilson Wingston Sharon
wingston.sharon@gmail.com
Le me
• Day job python developer.

• Hobby technologies

  o Machine Learning

  o Hardware Hacking

  o Image processing

  o Graphics & Video design
Introduction
• Open Computer Vision (OpenCV) developed &
  donated to FOSS by Intel.

• Open Source Image Processing library in C/C++

• Optimized for real time image / video processing
  applications

• OS/hardware independent with ports to Java,
  Python with wrappers to numerous other languages
  and platforms.
Why OpenCV?
• No need to reinvent the wheel to deal with image
  processing solutions.

• Has both high level and low level components.

• Lets you treat images as a 2D Matrix.
• Image processing comes down to simple mathematical
  operations on this Matrix.

• Also provides a framework for machine learning, 3D
  scene information, depth profile, object recognition,
  motion tracking etc..
Suiting up
• Sun JDK 6
   o Very important you DO NOT use Sun JDK 7. unless you want to deal with intermittent
     weird run time issues that make no sense. In that case go right ahead.


• Android SDK + NDK
   o Keep it updated once in a while.
   o Remember:You need “ia32-lib” if you’re running a 64 bit ubuntu/debian
   o NDK is required only if native code is erquired to be compiled.


• Android SDK tools rev14+
   o fun fact: using older versions can cause heartburn.


• SDK Platform API 8 is minimum required
   o But usually a device running 11 would have the processing power you need to play with
     image processing application without lag.


• Eclipse with ADT + CDT
   o Duh.
OpenCV4Android SDK
• Obtain CV-2.4.2-android-sdk.zip from sourceforge.
• SDK
   o Contains the openCV libraries and Java classes for Android.
   o /java, /native and /etc


• APK
   o Opencv manager apk that must be installed to make the openCV libaries on the
     android device available.
   o Android market installation can also be done.


• Samples
   o Contains a decent amount of openCV samples for android.
   o These samples are written as documentation.


   o See the openCV wiki for setting up Eclipse with OpenCV.
Overview of some
 openCV classes
   in /sdk/java
org.opencv.android

• Contains the Async loader that you’ll need
  to connect your application to the openCV
  libraries installed on your device.

• Utility function to convert between
  openCV data types and android ones.

• Some other loader classes for your
  viewing pleasure.
org.opencv.core

•Contains the core building blocks of openCV
•Matrix, point, rect and Bitmap data types
 defined here.

org.opencv.highgui

•Allows you to draw some GUI components
 on the screen.
•Also has the openCV videcapture class as an
 alternative to the android camera interface.
org.opencv.imgproc

• The main image processing functions exist here,
  like blurring edge detection, colour conversion.
• This file also contains documentation and usage
  of each function.

org.openCV.ml

• Contains classes to assist in developing almost
  any machine learning algorithm in images.
• Trees, statistical models, Bayes, Markov models, K
  nearest all provided here with in-code
  commented documentation
Programming
methodology
The application structure
• Best way (as suggested in samples) is as follows.

• MainActivity
   o Extends the android activity class & is the Launcher Activity.
   o Initializes the openCV libraries.
   o Handles the android activity lifecycle functions.

• opencvView
   o Extends opencvViewBase
   o Running openCV code goes here.

• opencvViewBase
   o Extends surfaceView as a holder for the video stream
   o Abstract class to simplify usage of OpenCV
   o Sets up and handles camera / preview & drawing
MainActivity.java
• onCreate()
   o This is called when the activity is first created.
   o OpenCVLoader.initAsync(…) attempts to start the openCV library and on
     completion calls mOpenCVCallBack.


• mOpenCVCallBack()
   o Inside there is a function called onManagerConnected() which checks to
     see if no errors were there
   o If openCV loaded sucessfully, then an instance of Sample1View can be
     created called say mView


• Also this class has the onPause(), onResume()
  functions which start / stop camera streaming as
  per the android activity lifecycle.
opencvView.java
• This class contains code relevant for your application, this
  directly extends the absract opencvViewBase class.

• processFrame(byte[] data)
   o Input comes in as byte[] data as raw camera feed

   o Using the mat.put() this picture can be stored in a matrix

   o Any openCV functions from imgproc etc.. can be performed on
     this mat object

   o Display must be in bitmap format, so the mat object is converted
     to bmp

   o This bmp object is returned to run() which displays it on the screen.
• Camera mCamera;
   o Camera object to open/close/ retrieve video information


• SurfaceHolder mHolder;
   o Holder to the surfaceview to enable a live streaming of video


• Mat mRgba;
   o Matrix Object that openCV uses for image manipulation


• Bitmap mBitmap;
   o Bitmap object that can be displayed on the surface view


• mRgba.put(0, 0, data);
   o Returns the raw data feed in an openCV matrix format.


• Imgproc.cvtColor(mGraySubmat, mRgba,
  Imgproc.COLOR_GRAY2RGBA, 4);
   o How to convert an RGB matrix to a greyscale


• Utils.matToBitmap(mRgba, bmp);
   o Converting a matrix to a bitmap
Real Time Applications
Real time Face detection
• fdActivity example is an openCV sample that shows how to
  implement face detection algorithm on a real time video
  stream.

• It is also an example on how to efficiently implement an
  algorithm in C and call it via the JNI interface.

• Also implements an FPS meter class to judge the usability of
  the algorithm used.

• A Haar Classifier from the ml library with the openCV trained
  xml file is used on the image stream to return if the image
  contains a face or not.

• It is the standard openCV way of face detetcion.
Possible Applications on
     android devices
• Obtain features from any image and send it over
  network for matching against an online database
  for object recognition.

• Use the front camera to monitor head movement
  and provide a hands free interface for some
  games.

• Auto-tagging of friends in photos taken and
  associating them with facebook/android contacts.
Thank You..

Any Questions?

wingston.sharon@gmail.com

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
 
"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
 
PyCon 2012: Militarizing Your Backyard: Computer Vision and the Squirrel Hordes
PyCon 2012: Militarizing Your Backyard: Computer Vision and the Squirrel HordesPyCon 2012: Militarizing Your Backyard: Computer Vision and the Squirrel Hordes
PyCon 2012: Militarizing Your Backyard: Computer Vision and the Squirrel Hordes
kgrandis
 
"OpenCV: Current Status and Future Plans," a Presentation from OpenCV.org
"OpenCV: Current Status and Future Plans," a Presentation from OpenCV.org"OpenCV: Current Status and Future Plans," a Presentation from OpenCV.org
"OpenCV: Current Status and Future Plans," a Presentation from OpenCV.org
Edge AI and Vision Alliance
 

What's hot (11)

"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...
 
A high level introduction to OpenCV
A high level introduction to OpenCVA high level introduction to OpenCV
A high level introduction to OpenCV
 
OpenCV Workshop
OpenCV WorkshopOpenCV Workshop
OpenCV Workshop
 
"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...
 
PyCon 2012: Militarizing Your Backyard: Computer Vision and the Squirrel Hordes
PyCon 2012: Militarizing Your Backyard: Computer Vision and the Squirrel HordesPyCon 2012: Militarizing Your Backyard: Computer Vision and the Squirrel Hordes
PyCon 2012: Militarizing Your Backyard: Computer Vision and the Squirrel Hordes
 
Open Cv
Open CvOpen Cv
Open Cv
 
openCV with python
openCV with pythonopenCV with python
openCV with python
 
"OpenCV: Current Status and Future Plans," a Presentation from OpenCV.org
"OpenCV: Current Status and Future Plans," a Presentation from OpenCV.org"OpenCV: Current Status and Future Plans," a Presentation from OpenCV.org
"OpenCV: Current Status and Future Plans," a Presentation from OpenCV.org
 
Introduction to OpenCV 2.3.1
Introduction to OpenCV 2.3.1Introduction to OpenCV 2.3.1
Introduction to OpenCV 2.3.1
 
On technology transfer: experience from the CARP project... and beyond
On technology transfer: experience from the CARP project... and beyondOn technology transfer: experience from the CARP project... and beyond
On technology transfer: experience from the CARP project... and beyond
 
Unity 3 d-with-c
Unity 3 d-with-cUnity 3 d-with-c
Unity 3 d-with-c
 

Viewers also liked

Arm cortex-m3 by-joe_bungo_arm
Arm cortex-m3 by-joe_bungo_armArm cortex-m3 by-joe_bungo_arm
Arm cortex-m3 by-joe_bungo_arm
Prashant Ahire
 
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
Chu Lam
 
Projeto Jornal Escolar Wilson De Almeida
Projeto Jornal Escolar   Wilson De AlmeidaProjeto Jornal Escolar   Wilson De Almeida
Projeto Jornal Escolar Wilson De Almeida
Ana Claudia
 

Viewers also liked (13)

Image Processing with OpenCV
Image Processing with OpenCVImage Processing with OpenCV
Image Processing with OpenCV
 
Myro and OpenCV
Myro and OpenCVMyro and OpenCV
Myro and OpenCV
 
RoboCV Module 4: Image Processing Techniques using OpenCV
RoboCV Module 4: Image Processing Techniques using OpenCVRoboCV Module 4: Image Processing Techniques using OpenCV
RoboCV Module 4: Image Processing Techniques using OpenCV
 
RoboCV Module 2: Introduction to OpenCV and MATLAB
RoboCV Module 2: Introduction to OpenCV and MATLABRoboCV Module 2: Introduction to OpenCV and MATLAB
RoboCV Module 2: Introduction to OpenCV and MATLAB
 
Getting started with open cv in raspberry pi
Getting started with open cv in raspberry piGetting started with open cv in raspberry pi
Getting started with open cv in raspberry pi
 
Using openCV on Raspberry Pi
Using openCV on Raspberry PiUsing openCV on Raspberry Pi
Using openCV on Raspberry Pi
 
Arm cortex-m3 by-joe_bungo_arm
Arm cortex-m3 by-joe_bungo_armArm cortex-m3 by-joe_bungo_arm
Arm cortex-m3 by-joe_bungo_arm
 
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
 
OpenCV Introduction
OpenCV IntroductionOpenCV Introduction
OpenCV Introduction
 
Radar 2009 a 15 parameter estimation and tracking part 1
Radar 2009 a 15 parameter estimation and tracking part 1Radar 2009 a 15 parameter estimation and tracking part 1
Radar 2009 a 15 parameter estimation and tracking part 1
 
Projeto Jornal Escolar Wilson De Almeida
Projeto Jornal Escolar   Wilson De AlmeidaProjeto Jornal Escolar   Wilson De Almeida
Projeto Jornal Escolar Wilson De Almeida
 
ARM CORTEX M3 PPT
ARM CORTEX M3 PPTARM CORTEX M3 PPT
ARM CORTEX M3 PPT
 
Q4.11: ARM Architecture
Q4.11: ARM ArchitectureQ4.11: ARM Architecture
Q4.11: ARM Architecture
 

Similar to OpenCV @ Droidcon 2012

502021435-12345678Minor-Project-Ppt.pptx
502021435-12345678Minor-Project-Ppt.pptx502021435-12345678Minor-Project-Ppt.pptx
502021435-12345678Minor-Project-Ppt.pptx
shrey4922
 
Implementation of embedded arm9 platform using qt and open cv for human upper...
Implementation of embedded arm9 platform using qt and open cv for human upper...Implementation of embedded arm9 platform using qt and open cv for human upper...
Implementation of embedded arm9 platform using qt and open cv for human upper...
Krunal Patel
 
A Tutorial On Ip 2
A Tutorial On Ip 2A Tutorial On Ip 2
A Tutorial On Ip 2
ankuredkie
 

Similar to OpenCV @ Droidcon 2012 (20)

502021435-12345678Minor-Project-Ppt.pptx
502021435-12345678Minor-Project-Ppt.pptx502021435-12345678Minor-Project-Ppt.pptx
502021435-12345678Minor-Project-Ppt.pptx
 
“OpenCV: Past, Present and Future,” a Presentation from OpenCV.org
“OpenCV: Past, Present and Future,” a Presentation from OpenCV.org“OpenCV: Past, Present and Future,” a Presentation from OpenCV.org
“OpenCV: Past, Present and Future,” a Presentation from OpenCV.org
 
OpenCV+Android.pptx
OpenCV+Android.pptxOpenCV+Android.pptx
OpenCV+Android.pptx
 
Automatic License Plate Recognition using OpenCV
Automatic License Plate Recognition using OpenCVAutomatic License Plate Recognition using OpenCV
Automatic License Plate Recognition using OpenCV
 
Automatic License Plate Recognition using OpenCV
Automatic License Plate Recognition using OpenCV Automatic License Plate Recognition using OpenCV
Automatic License Plate Recognition using OpenCV
 
Implementation of embedded arm9 platform using qt and open cv for human upper...
Implementation of embedded arm9 platform using qt and open cv for human upper...Implementation of embedded arm9 platform using qt and open cv for human upper...
Implementation of embedded arm9 platform using qt and open cv for human upper...
 
Starting with OpenCV on i.MX 6 Processors
Starting with OpenCV on i.MX 6 ProcessorsStarting with OpenCV on i.MX 6 Processors
Starting with OpenCV on i.MX 6 Processors
 
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)
 
Surge2012
Surge2012Surge2012
Surge2012
 
Everything you need to know about GraalVM Native Image
Everything you need to know about GraalVM Native ImageEverything you need to know about GraalVM Native Image
Everything you need to know about GraalVM Native Image
 
Opencv
OpencvOpencv
Opencv
 
Install, Compile, Setup, Setting OpenCV 3.2, Visual C++ 2015, Win 64bit,
Install, Compile, Setup, Setting OpenCV 3.2, Visual C++ 2015, Win 64bit, Install, Compile, Setup, Setting OpenCV 3.2, Visual C++ 2015, Win 64bit,
Install, Compile, Setup, Setting OpenCV 3.2, Visual C++ 2015, Win 64bit,
 
Java1 in mumbai
Java1 in mumbaiJava1 in mumbai
Java1 in mumbai
 
Modern application development with oracle cloud sangam17
Modern application development with oracle cloud sangam17Modern application development with oracle cloud sangam17
Modern application development with oracle cloud sangam17
 
A Tutorial On Ip 2
A Tutorial On Ip 2A Tutorial On Ip 2
A Tutorial On Ip 2
 
How To Install OpenCV On Windows? Edureka
How To Install OpenCV On Windows? EdurekaHow To Install OpenCV On Windows? Edureka
How To Install OpenCV On Windows? Edureka
 
JDK Tools For Performance Diagnostics
JDK Tools For Performance DiagnosticsJDK Tools For Performance Diagnostics
JDK Tools For Performance Diagnostics
 
Dynamic Languages in Production: Progress and Open Challenges
Dynamic Languages in Production: Progress and Open ChallengesDynamic Languages in Production: Progress and Open Challenges
Dynamic Languages in Production: Progress and Open Challenges
 
Autonomous Machines with Project Bonsai
Autonomous Machines with Project BonsaiAutonomous Machines with Project Bonsai
Autonomous Machines with Project Bonsai
 
Node.js Native AddOns from zero to hero - Nicola Del Gobbo - Codemotion Rome ...
Node.js Native AddOns from zero to hero - Nicola Del Gobbo - Codemotion Rome ...Node.js Native AddOns from zero to hero - Nicola Del Gobbo - Codemotion Rome ...
Node.js Native AddOns from zero to hero - Nicola Del Gobbo - Codemotion Rome ...
 

More from Wingston

03 layouts & ui design - Android
03   layouts & ui design - Android03   layouts & ui design - Android
03 layouts & ui design - Android
Wingston
 
Linux – an introduction
Linux – an introductionLinux – an introduction
Linux – an introduction
Wingston
 
Introduction to the Arduino
Introduction to the ArduinoIntroduction to the Arduino
Introduction to the Arduino
Wingston
 
4.content mgmt
4.content mgmt4.content mgmt
4.content mgmt
Wingston
 
8 Web Practices for Drupal
8  Web Practices for Drupal8  Web Practices for Drupal
8 Web Practices for Drupal
Wingston
 
7 Theming in Drupal
7 Theming in Drupal7 Theming in Drupal
7 Theming in Drupal
Wingston
 
6 Special Howtos for Drupal
6 Special Howtos for Drupal6 Special Howtos for Drupal
6 Special Howtos for Drupal
Wingston
 
5 User Mgmt in Drupal
5 User Mgmt in Drupal5 User Mgmt in Drupal
5 User Mgmt in Drupal
Wingston
 

More from Wingston (20)

05 content providers - Android
05   content providers - Android05   content providers - Android
05 content providers - Android
 
04 activities - Android
04   activities - Android04   activities - Android
04 activities - Android
 
03 layouts & ui design - Android
03   layouts & ui design - Android03   layouts & ui design - Android
03 layouts & ui design - Android
 
02 hello world - Android
02   hello world - Android02   hello world - Android
02 hello world - Android
 
01 introduction & setup - Android
01   introduction & setup - Android01   introduction & setup - Android
01 introduction & setup - Android
 
C game programming - SDL
C game programming - SDLC game programming - SDL
C game programming - SDL
 
C programming - Pointers
C programming - PointersC programming - Pointers
C programming - Pointers
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02
 
Introduction to Basic C programming 01
Introduction to Basic C programming 01Introduction to Basic C programming 01
Introduction to Basic C programming 01
 
Linux – an introduction
Linux – an introductionLinux – an introduction
Linux – an introduction
 
Embedded linux
Embedded linuxEmbedded linux
Embedded linux
 
04 Arduino Peripheral Interfacing
04   Arduino Peripheral Interfacing04   Arduino Peripheral Interfacing
04 Arduino Peripheral Interfacing
 
03 analogue anrduino fundamentals
03   analogue anrduino fundamentals03   analogue anrduino fundamentals
03 analogue anrduino fundamentals
 
02 General Purpose Input - Output on the Arduino
02   General Purpose Input -  Output on the Arduino02   General Purpose Input -  Output on the Arduino
02 General Purpose Input - Output on the Arduino
 
Introduction to the Arduino
Introduction to the ArduinoIntroduction to the Arduino
Introduction to the Arduino
 
4.content mgmt
4.content mgmt4.content mgmt
4.content mgmt
 
8 Web Practices for Drupal
8  Web Practices for Drupal8  Web Practices for Drupal
8 Web Practices for Drupal
 
7 Theming in Drupal
7 Theming in Drupal7 Theming in Drupal
7 Theming in Drupal
 
6 Special Howtos for Drupal
6 Special Howtos for Drupal6 Special Howtos for Drupal
6 Special Howtos for Drupal
 
5 User Mgmt in Drupal
5 User Mgmt in Drupal5 User Mgmt in Drupal
5 User Mgmt in Drupal
 

Recently uploaded

“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
Muhammad Subhan
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
FIDO Alliance
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
FIDO Alliance
 

Recently uploaded (20)

“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
 
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 
Using IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandUsing IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & Ireland
 
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - Questionnaire
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
 
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
 
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdfFrisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM Performance
 
Top 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTop 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development Companies
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptxCyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cf
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
 
Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoft
 

OpenCV @ Droidcon 2012

  • 1. OpenCV Image Processing on Android Devices Wilson Wingston Sharon wingston.sharon@gmail.com
  • 2. Le me • Day job python developer. • Hobby technologies o Machine Learning o Hardware Hacking o Image processing o Graphics & Video design
  • 3. Introduction • Open Computer Vision (OpenCV) developed & donated to FOSS by Intel. • Open Source Image Processing library in C/C++ • Optimized for real time image / video processing applications • OS/hardware independent with ports to Java, Python with wrappers to numerous other languages and platforms.
  • 4. Why OpenCV? • No need to reinvent the wheel to deal with image processing solutions. • Has both high level and low level components. • Lets you treat images as a 2D Matrix. • Image processing comes down to simple mathematical operations on this Matrix. • Also provides a framework for machine learning, 3D scene information, depth profile, object recognition, motion tracking etc..
  • 5. Suiting up • Sun JDK 6 o Very important you DO NOT use Sun JDK 7. unless you want to deal with intermittent weird run time issues that make no sense. In that case go right ahead. • Android SDK + NDK o Keep it updated once in a while. o Remember:You need “ia32-lib” if you’re running a 64 bit ubuntu/debian o NDK is required only if native code is erquired to be compiled. • Android SDK tools rev14+ o fun fact: using older versions can cause heartburn. • SDK Platform API 8 is minimum required o But usually a device running 11 would have the processing power you need to play with image processing application without lag. • Eclipse with ADT + CDT o Duh.
  • 6. OpenCV4Android SDK • Obtain CV-2.4.2-android-sdk.zip from sourceforge. • SDK o Contains the openCV libraries and Java classes for Android. o /java, /native and /etc • APK o Opencv manager apk that must be installed to make the openCV libaries on the android device available. o Android market installation can also be done. • Samples o Contains a decent amount of openCV samples for android. o These samples are written as documentation. o See the openCV wiki for setting up Eclipse with OpenCV.
  • 7. Overview of some openCV classes in /sdk/java
  • 8. org.opencv.android • Contains the Async loader that you’ll need to connect your application to the openCV libraries installed on your device. • Utility function to convert between openCV data types and android ones. • Some other loader classes for your viewing pleasure.
  • 9. org.opencv.core •Contains the core building blocks of openCV •Matrix, point, rect and Bitmap data types defined here. org.opencv.highgui •Allows you to draw some GUI components on the screen. •Also has the openCV videcapture class as an alternative to the android camera interface.
  • 10. org.opencv.imgproc • The main image processing functions exist here, like blurring edge detection, colour conversion. • This file also contains documentation and usage of each function. org.openCV.ml • Contains classes to assist in developing almost any machine learning algorithm in images. • Trees, statistical models, Bayes, Markov models, K nearest all provided here with in-code commented documentation
  • 12. The application structure • Best way (as suggested in samples) is as follows. • MainActivity o Extends the android activity class & is the Launcher Activity. o Initializes the openCV libraries. o Handles the android activity lifecycle functions. • opencvView o Extends opencvViewBase o Running openCV code goes here. • opencvViewBase o Extends surfaceView as a holder for the video stream o Abstract class to simplify usage of OpenCV o Sets up and handles camera / preview & drawing
  • 13. MainActivity.java • onCreate() o This is called when the activity is first created. o OpenCVLoader.initAsync(…) attempts to start the openCV library and on completion calls mOpenCVCallBack. • mOpenCVCallBack() o Inside there is a function called onManagerConnected() which checks to see if no errors were there o If openCV loaded sucessfully, then an instance of Sample1View can be created called say mView • Also this class has the onPause(), onResume() functions which start / stop camera streaming as per the android activity lifecycle.
  • 14. opencvView.java • This class contains code relevant for your application, this directly extends the absract opencvViewBase class. • processFrame(byte[] data) o Input comes in as byte[] data as raw camera feed o Using the mat.put() this picture can be stored in a matrix o Any openCV functions from imgproc etc.. can be performed on this mat object o Display must be in bitmap format, so the mat object is converted to bmp o This bmp object is returned to run() which displays it on the screen.
  • 15. • Camera mCamera; o Camera object to open/close/ retrieve video information • SurfaceHolder mHolder; o Holder to the surfaceview to enable a live streaming of video • Mat mRgba; o Matrix Object that openCV uses for image manipulation • Bitmap mBitmap; o Bitmap object that can be displayed on the surface view • mRgba.put(0, 0, data); o Returns the raw data feed in an openCV matrix format. • Imgproc.cvtColor(mGraySubmat, mRgba, Imgproc.COLOR_GRAY2RGBA, 4); o How to convert an RGB matrix to a greyscale • Utils.matToBitmap(mRgba, bmp); o Converting a matrix to a bitmap
  • 17. Real time Face detection • fdActivity example is an openCV sample that shows how to implement face detection algorithm on a real time video stream. • It is also an example on how to efficiently implement an algorithm in C and call it via the JNI interface. • Also implements an FPS meter class to judge the usability of the algorithm used. • A Haar Classifier from the ml library with the openCV trained xml file is used on the image stream to return if the image contains a face or not. • It is the standard openCV way of face detetcion.
  • 18. Possible Applications on android devices • Obtain features from any image and send it over network for matching against an online database for object recognition. • Use the front camera to monitor head movement and provide a hands free interface for some games. • Auto-tagging of friends in photos taken and associating them with facebook/android contacts.