SlideShare a Scribd company logo
Why camera?
●   Kind of light sensor :)
●   Take pictures, record video
●   Background image for AR
    ●   Layar
●   Input for computer vision/image processing
    ●   Pose estimation
    ●   Heartbeat
    ●   Spectrometer
Outline
●   Why is camera important
●   Camera API
●   Basic usage
●   Camera in emulator
●   Image formats
Camera API
●   Permissions

●   import android.hardware.Camera;
●   Open/release
    ●   Constructor is private => Camera.open()
●   Where is display?
    ●   Create your own extending SurfaceView
    ●   Add to activity using setContentView
Image pipeline
Typical usage



                     get instance of SurfaceHolder



                         register for callback
                     on surface create and destroy




         set buffer type to
  SURFACE_TYPE_PUSH_BUFFERS
Typical usage (contd.)
    called once the surface was fully initialized




                                    get instance of camera




                                      set fully initialized surface
                                                to camera
Typical usage (contd.)
          called when surface size changes




                              stop preview just to be sure




                                             set width&height
                                          for the camera picture

    tell camera to start
 sending frames to surface
Typical usage (contd.)
      called when surface is destroyed




                                         stop preview


                                     important!
                              camera is shared resource
Demo
Webcam in emulator
●   Don't do that
●   Emulator
    ●   Infinite sample loop (box over checkers)
    ●   Custom SocketCamera
        –   Video input from webcam is sent to server on emulator
        –   Really slow
    ●   Only for quick prototype
●   Real phone is much better
Processing camera input
●   Before Froyo (Android 1.0-2.1)
    ●
        setPreviewCallback β†’ onPreviewFrame




●   Froyo and beyond (Android 2.2)
    ●   Create&reuse your own buffer - addCallbackBuffer
    ●
        setPreviewCallbackWithBuffer β†’ onPreviewFrame
    ●   After processing data from buffer add it back to
        queue using addCallbackBuffer
What is in byte[] data?
●   Image byte by byte
●   PixelFormat – YUV/NV21, RGB565
    ●   Luckily many algorithms work in grayscale
●   YUV (YCbCr_420_SP/NV21)
What is in byte[] data? (contd.)
●   YUV (YCbCr_420_SP/NV21)
    ●   Default format (on older versions the only available)
    ●   Full greyscale (people are more sensitive)
        –   First width*height bytes
    ●   Subsampled blue and red (chroma)
    ●   Use greyscale - first width*height bytes – and don't
        bother with the rest
What is in byte[] data? (contd.)
●   RGB565 – 16 bits – 2 bytes per pixel
          5         6         5
    ●   RRRRRGGG|GGGBBBBB
         data[2n]       data[2n+1]
What is camera actually?
Issues
●   Slow – 15 ps
●   Blurred at low light
●   Narrower angle of view
●   Rolling shutter (no global shutter) – skewed
    image
Issues (contd.)
●   Getting image from sensor takes time – smaller
    time slot for calculations
    ●   Caution - onPreviewFrame called too many times
        when you do much processing =>
        setOneShotPreviewCallback
●   Distortion
More fun with camera
●   Do something with computer vision
    ●   We worked with OpenCV on android
        –   Works but be careful about performance
    ●   Edge detection
    ●   Feature tracking
    ●   Face detection
●   Motion detection
●   Daylight sensor
●   Whatever you can think of :)
Use the source, Luke!
●   http://android.git.kernel.org
    is your friend

●   Camera:
    ●   [platform/frameworks/base.git]
        /core/java/android/hardware
        /Camera.java
    ●   [platform/frameworks/base.git]
        /jni/android_hardware_Camera.cpp

More Related Content

What's hot

Android Components
Android ComponentsAndroid Components
Android Components
Aatul Palandurkar
Β 
Android ppt
Android pptAndroid ppt
Android ppt
Ansh Singh
Β 
Multimedia on android
Multimedia on androidMultimedia on android
Multimedia on android
Ramesh Prasad
Β 
The Android graphics path, in depth
The Android graphics path, in depthThe Android graphics path, in depth
The Android graphics path, in depth
Chris Simmonds
Β 
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...Opersys inc.
Β 
Design and Concepts of Android Graphics
Design and Concepts of Android GraphicsDesign and Concepts of Android Graphics
Design and Concepts of Android Graphics
National Cheng Kung University
Β 
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
Nanik Tolaram
Β 
Android Development: The Basics
Android Development: The BasicsAndroid Development: The Basics
Android Development: The Basics
Mike Desjardins
Β 
Android activity lifecycle
Android activity lifecycleAndroid activity lifecycle
Android activity lifecycle
Soham Patel
Β 
Android internals By Rajesh Khetan
Android internals By Rajesh KhetanAndroid internals By Rajesh Khetan
Android internals By Rajesh Khetan
Rajesh Khetan
Β 
Mobile operating system (os)
Mobile operating system (os)Mobile operating system (os)
Mobile operating system (os)
AMIT GUPTA
Β 
Android booting sequece and setup and debugging
Android booting sequece and setup and debuggingAndroid booting sequece and setup and debugging
Android booting sequece and setup and debuggingUtkarsh Mankad
Β 
Windows Phone PPT
Windows Phone PPTWindows Phone PPT
Windows Phone PPT
deepak171991
Β 
Android vs windows
Android vs windowsAndroid vs windows
Android vs windows
SHARDA SHARAN
Β 
Learning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device DriverLearning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device Driver
Nanik Tolaram
Β 
android-tutorial-for-beginner
android-tutorial-for-beginnerandroid-tutorial-for-beginner
android-tutorial-for-beginnerAjailal Parackal
Β 
Understaing Android EGL
Understaing Android EGLUnderstaing Android EGL
Understaing Android EGL
Suhan Lee
Β 
Windows server2016 presentation
Windows server2016 presentation Windows server2016 presentation
Windows server2016 presentation
☁️Seyfallah Tagrerout☁ [MVP]
Β 
Introduction to android
Introduction to androidIntroduction to android
Introduction to android
zeelpatel0504
Β 

What's hot (20)

Android Components
Android ComponentsAndroid Components
Android Components
Β 
Android ppt
Android pptAndroid ppt
Android ppt
Β 
Multimedia on android
Multimedia on androidMultimedia on android
Multimedia on android
Β 
The Android graphics path, in depth
The Android graphics path, in depthThe Android graphics path, in depth
The Android graphics path, in depth
Β 
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Β 
Design and Concepts of Android Graphics
Design and Concepts of Android GraphicsDesign and Concepts of Android Graphics
Design and Concepts of Android Graphics
Β 
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
Β 
Android Development: The Basics
Android Development: The BasicsAndroid Development: The Basics
Android Development: The Basics
Β 
Android activity lifecycle
Android activity lifecycleAndroid activity lifecycle
Android activity lifecycle
Β 
Android internals By Rajesh Khetan
Android internals By Rajesh KhetanAndroid internals By Rajesh Khetan
Android internals By Rajesh Khetan
Β 
Mobile operating system (os)
Mobile operating system (os)Mobile operating system (os)
Mobile operating system (os)
Β 
Android booting sequece and setup and debugging
Android booting sequece and setup and debuggingAndroid booting sequece and setup and debugging
Android booting sequece and setup and debugging
Β 
Windows Phone PPT
Windows Phone PPTWindows Phone PPT
Windows Phone PPT
Β 
Android vs windows
Android vs windowsAndroid vs windows
Android vs windows
Β 
Android ppt
Android ppt Android ppt
Android ppt
Β 
Learning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device DriverLearning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device Driver
Β 
android-tutorial-for-beginner
android-tutorial-for-beginnerandroid-tutorial-for-beginner
android-tutorial-for-beginner
Β 
Understaing Android EGL
Understaing Android EGLUnderstaing Android EGL
Understaing Android EGL
Β 
Windows server2016 presentation
Windows server2016 presentation Windows server2016 presentation
Windows server2016 presentation
Β 
Introduction to android
Introduction to androidIntroduction to android
Introduction to android
Β 

Viewers also liked

Building a Custom Camera Application in Android
Building a Custom Camera Application in AndroidBuilding a Custom Camera Application in Android
Building a Custom Camera Application in Android
Huyen Dao
Β 
Droidcon NYC 2014: Building Custom Camera Applications
Droidcon NYC 2014: Building Custom Camera ApplicationsDroidcon NYC 2014: Building Custom Camera Applications
Droidcon NYC 2014: Building Custom Camera Applications
Huyen Tue Dao
Β 
Wifi api android
Wifi api androidWifi api android
Wifi api androidTim ArtLaw
Β 
Android Wi-Fi Manager and Bluetooth Connection
Android Wi-Fi Manager and Bluetooth ConnectionAndroid Wi-Fi Manager and Bluetooth Connection
Android Wi-Fi Manager and Bluetooth ConnectionJussi Pohjolainen
Β 
Android Audio & OpenSL
Android Audio & OpenSLAndroid Audio & OpenSL
Android Audio & OpenSL
Yoss Cohen
Β 
Camera obscura pinhole
Camera obscura pinholeCamera obscura pinhole
Camera obscura pinholeINS Tremp
Β 
The history of the pinhole camera
The history of the pinhole cameraThe history of the pinhole camera
The history of the pinhole camera
tianaphoto
Β 
Android media framework overview
Android media framework overviewAndroid media framework overview
Android media framework overview
Jerrin George
Β 
Booting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot imagesBooting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot images
Chris Simmonds
Β 

Viewers also liked (9)

Building a Custom Camera Application in Android
Building a Custom Camera Application in AndroidBuilding a Custom Camera Application in Android
Building a Custom Camera Application in Android
Β 
Droidcon NYC 2014: Building Custom Camera Applications
Droidcon NYC 2014: Building Custom Camera ApplicationsDroidcon NYC 2014: Building Custom Camera Applications
Droidcon NYC 2014: Building Custom Camera Applications
Β 
Wifi api android
Wifi api androidWifi api android
Wifi api android
Β 
Android Wi-Fi Manager and Bluetooth Connection
Android Wi-Fi Manager and Bluetooth ConnectionAndroid Wi-Fi Manager and Bluetooth Connection
Android Wi-Fi Manager and Bluetooth Connection
Β 
Android Audio & OpenSL
Android Audio & OpenSLAndroid Audio & OpenSL
Android Audio & OpenSL
Β 
Camera obscura pinhole
Camera obscura pinholeCamera obscura pinhole
Camera obscura pinhole
Β 
The history of the pinhole camera
The history of the pinhole cameraThe history of the pinhole camera
The history of the pinhole camera
Β 
Android media framework overview
Android media framework overviewAndroid media framework overview
Android media framework overview
Β 
Booting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot imagesBooting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot images
Β 

Similar to Android Camera

Hidden Camera 3 APIs in Android 4.4 (KitKat)
Hidden Camera 3 APIs in Android 4.4 (KitKat)Hidden Camera 3 APIs in Android 4.4 (KitKat)
Hidden Camera 3 APIs in Android 4.4 (KitKat)
Balwinder Kaur
Β 
qtdd11_qtmultimediakitonmobile
qtdd11_qtmultimediakitonmobileqtdd11_qtmultimediakitonmobile
qtdd11_qtmultimediakitonmobile
gareth_stockwell
Β 
Flowframes
FlowframesFlowframes
Flowframes
Artmiker Studios
Β 
Inside Android's UI
Inside Android's UIInside Android's UI
Inside Android's UI
Opersys inc.
Β 
Inside Android's UI / ABS 2013
Inside Android's UI / ABS 2013Inside Android's UI / ABS 2013
Inside Android's UI / ABS 2013
Opersys inc.
Β 
Inside Android's UI at AnDevCon VI
Inside Android's UI at AnDevCon VIInside Android's UI at AnDevCon VI
Inside Android's UI at AnDevCon VIOpersys inc.
Β 
Inside Android's UI at AnDevCon V
Inside Android's UI at AnDevCon VInside Android's UI at AnDevCon V
Inside Android's UI at AnDevCon VOpersys inc.
Β 
Android 5.0 Camera2 APIs
Android 5.0 Camera2 APIsAndroid 5.0 Camera2 APIs
Android 5.0 Camera2 APIs
Balwinder Kaur
Β 
Alex_Vlachos_Advanced_VR_Rendering_GDC2015
Alex_Vlachos_Advanced_VR_Rendering_GDC2015Alex_Vlachos_Advanced_VR_Rendering_GDC2015
Alex_Vlachos_Advanced_VR_Rendering_GDC2015Alex Vlachos
Β 
How to deal with Fragmentation on Android
How to deal with Fragmentation on AndroidHow to deal with Fragmentation on Android
How to deal with Fragmentation on Android
Sittiphol Phanvilai
Β 
Sony HXR-NX70E Operation Manual
Sony HXR-NX70E Operation ManualSony HXR-NX70E Operation Manual
Sony HXR-NX70E Operation ManualAV ProfShop
Β 
Practical SPU Programming in God of War III
Practical SPU Programming in God of War IIIPractical SPU Programming in God of War III
Practical SPU Programming in God of War III
Slide_N
Β 
Smedberg niklas bringing_aaa_graphics
Smedberg niklas bringing_aaa_graphicsSmedberg niklas bringing_aaa_graphics
Smedberg niklas bringing_aaa_graphicschangehee lee
Β 
Virtual projector
Virtual projectorVirtual projector
Virtual projector
Alessandro Florio
Β 
AGDK tutorial step by step
AGDK tutorial step by stepAGDK tutorial step by step
AGDK tutorial step by step
Jungsoo Nam
Β 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
Opersys inc.
Β 
Gtug
GtugGtug
Gtug
Mohan Krk
Β 
Cloud Spin - building a photo booth with the Google Cloud Platform
Cloud Spin - building a photo booth with the Google Cloud PlatformCloud Spin - building a photo booth with the Google Cloud Platform
Cloud Spin - building a photo booth with the Google Cloud Platform
Bret McGowen - NYC Google Developer Advocate
Β 
Camera2 API: Overview
Camera2 API: OverviewCamera2 API: Overview
Camera2 API: Overview
Suhyun Park
Β 
VR Optimization Techniques
VR Optimization Techniques VR Optimization Techniques
VR Optimization Techniques
digitalagentsinteractive
Β 

Similar to Android Camera (20)

Hidden Camera 3 APIs in Android 4.4 (KitKat)
Hidden Camera 3 APIs in Android 4.4 (KitKat)Hidden Camera 3 APIs in Android 4.4 (KitKat)
Hidden Camera 3 APIs in Android 4.4 (KitKat)
Β 
qtdd11_qtmultimediakitonmobile
qtdd11_qtmultimediakitonmobileqtdd11_qtmultimediakitonmobile
qtdd11_qtmultimediakitonmobile
Β 
Flowframes
FlowframesFlowframes
Flowframes
Β 
Inside Android's UI
Inside Android's UIInside Android's UI
Inside Android's UI
Β 
Inside Android's UI / ABS 2013
Inside Android's UI / ABS 2013Inside Android's UI / ABS 2013
Inside Android's UI / ABS 2013
Β 
Inside Android's UI at AnDevCon VI
Inside Android's UI at AnDevCon VIInside Android's UI at AnDevCon VI
Inside Android's UI at AnDevCon VI
Β 
Inside Android's UI at AnDevCon V
Inside Android's UI at AnDevCon VInside Android's UI at AnDevCon V
Inside Android's UI at AnDevCon V
Β 
Android 5.0 Camera2 APIs
Android 5.0 Camera2 APIsAndroid 5.0 Camera2 APIs
Android 5.0 Camera2 APIs
Β 
Alex_Vlachos_Advanced_VR_Rendering_GDC2015
Alex_Vlachos_Advanced_VR_Rendering_GDC2015Alex_Vlachos_Advanced_VR_Rendering_GDC2015
Alex_Vlachos_Advanced_VR_Rendering_GDC2015
Β 
How to deal with Fragmentation on Android
How to deal with Fragmentation on AndroidHow to deal with Fragmentation on Android
How to deal with Fragmentation on Android
Β 
Sony HXR-NX70E Operation Manual
Sony HXR-NX70E Operation ManualSony HXR-NX70E Operation Manual
Sony HXR-NX70E Operation Manual
Β 
Practical SPU Programming in God of War III
Practical SPU Programming in God of War IIIPractical SPU Programming in God of War III
Practical SPU Programming in God of War III
Β 
Smedberg niklas bringing_aaa_graphics
Smedberg niklas bringing_aaa_graphicsSmedberg niklas bringing_aaa_graphics
Smedberg niklas bringing_aaa_graphics
Β 
Virtual projector
Virtual projectorVirtual projector
Virtual projector
Β 
AGDK tutorial step by step
AGDK tutorial step by stepAGDK tutorial step by step
AGDK tutorial step by step
Β 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
Β 
Gtug
GtugGtug
Gtug
Β 
Cloud Spin - building a photo booth with the Google Cloud Platform
Cloud Spin - building a photo booth with the Google Cloud PlatformCloud Spin - building a photo booth with the Google Cloud Platform
Cloud Spin - building a photo booth with the Google Cloud Platform
Β 
Camera2 API: Overview
Camera2 API: OverviewCamera2 API: Overview
Camera2 API: Overview
Β 
VR Optimization Techniques
VR Optimization Techniques VR Optimization Techniques
VR Optimization Techniques
Β 

Recently uploaded

FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
Β 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
Β 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
Β 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
Β 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
Β 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
Β 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
Β 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
Β 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
Β 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
Β 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilotβ„’
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilotβ„’Le nuove frontiere dell'AI nell'RPA con UiPath Autopilotβ„’
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilotβ„’
UiPathCommunity
Β 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
Β 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
Β 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
Β 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
Β 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
Β 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
Β 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
Β 
UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..
UiPathCommunity
Β 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
Β 

Recently uploaded (20)

FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
Β 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
Β 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
Β 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Β 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Β 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
Β 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Β 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Β 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Β 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Β 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilotβ„’
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilotβ„’Le nuove frontiere dell'AI nell'RPA con UiPath Autopilotβ„’
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilotβ„’
Β 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Β 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
Β 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
Β 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Β 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
Β 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Β 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Β 
UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..
Β 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
Β 

Android Camera

  • 1. Why camera? ● Kind of light sensor :) ● Take pictures, record video ● Background image for AR ● Layar ● Input for computer vision/image processing ● Pose estimation ● Heartbeat ● Spectrometer
  • 2. Outline ● Why is camera important ● Camera API ● Basic usage ● Camera in emulator ● Image formats
  • 3. Camera API ● Permissions ● import android.hardware.Camera; ● Open/release ● Constructor is private => Camera.open() ● Where is display? ● Create your own extending SurfaceView ● Add to activity using setContentView
  • 5. Typical usage get instance of SurfaceHolder register for callback on surface create and destroy set buffer type to SURFACE_TYPE_PUSH_BUFFERS
  • 6. Typical usage (contd.) called once the surface was fully initialized get instance of camera set fully initialized surface to camera
  • 7. Typical usage (contd.) called when surface size changes stop preview just to be sure set width&height for the camera picture tell camera to start sending frames to surface
  • 8. Typical usage (contd.) called when surface is destroyed stop preview important! camera is shared resource
  • 10. Webcam in emulator ● Don't do that ● Emulator ● Infinite sample loop (box over checkers) ● Custom SocketCamera – Video input from webcam is sent to server on emulator – Really slow ● Only for quick prototype ● Real phone is much better
  • 11. Processing camera input ● Before Froyo (Android 1.0-2.1) ● setPreviewCallback β†’ onPreviewFrame ● Froyo and beyond (Android 2.2) ● Create&reuse your own buffer - addCallbackBuffer ● setPreviewCallbackWithBuffer β†’ onPreviewFrame ● After processing data from buffer add it back to queue using addCallbackBuffer
  • 12. What is in byte[] data? ● Image byte by byte ● PixelFormat – YUV/NV21, RGB565 ● Luckily many algorithms work in grayscale ● YUV (YCbCr_420_SP/NV21)
  • 13. What is in byte[] data? (contd.) ● YUV (YCbCr_420_SP/NV21) ● Default format (on older versions the only available) ● Full greyscale (people are more sensitive) – First width*height bytes ● Subsampled blue and red (chroma) ● Use greyscale - first width*height bytes – and don't bother with the rest
  • 14. What is in byte[] data? (contd.) ● RGB565 – 16 bits – 2 bytes per pixel 5 6 5 ● RRRRRGGG|GGGBBBBB data[2n] data[2n+1]
  • 15. What is camera actually?
  • 16. Issues ● Slow – 15 ps ● Blurred at low light ● Narrower angle of view ● Rolling shutter (no global shutter) – skewed image
  • 17. Issues (contd.) ● Getting image from sensor takes time – smaller time slot for calculations ● Caution - onPreviewFrame called too many times when you do much processing => setOneShotPreviewCallback ● Distortion
  • 18. More fun with camera ● Do something with computer vision ● We worked with OpenCV on android – Works but be careful about performance ● Edge detection ● Feature tracking ● Face detection ● Motion detection ● Daylight sensor ● Whatever you can think of :)
  • 19. Use the source, Luke! ● http://android.git.kernel.org is your friend ● Camera: ● [platform/frameworks/base.git] /core/java/android/hardware /Camera.java ● [platform/frameworks/base.git] /jni/android_hardware_Camera.cpp