SlideShare ist ein Scribd-Unternehmen logo
1 von 19
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

Android Booting Sequence
Android Booting SequenceAndroid Booting Sequence
Android Booting SequenceJayanta Ghoshal
 
Learning AOSP - Android Booting Process
Learning AOSP - Android Booting ProcessLearning AOSP - Android Booting Process
Learning AOSP - Android Booting ProcessNanik Tolaram
 
Permission in Android Security: Threats and solution
Permission in Android Security: Threats and solutionPermission in Android Security: Threats and solution
Permission in Android Security: Threats and solutionTandhy Simanjuntak
 
Embedded Android Workshop
Embedded Android WorkshopEmbedded Android Workshop
Embedded Android WorkshopOpersys inc.
 
Android Storage - Vold
Android Storage - VoldAndroid Storage - Vold
Android Storage - VoldWilliam Lee
 
Multithreading in Android
Multithreading in AndroidMultithreading in Android
Multithreading in Androidcoolmirza143
 
Gpu presentation
Gpu presentationGpu presentation
Gpu presentationJosiah Lund
 
Learning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device DriverLearning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device DriverNanik Tolaram
 
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
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android DevelopmentAly Abdelkareem
 
Camera2 API, SHIM, and HAL 3.2 in Android 5.1
Camera2 API, SHIM, and HAL 3.2 in Android 5.1Camera2 API, SHIM, and HAL 3.2 in Android 5.1
Camera2 API, SHIM, and HAL 3.2 in Android 5.1Cheng Hsien Chen
 
Android crash debugging
Android crash debuggingAndroid crash debugging
Android crash debuggingAshish Agrawal
 

Was ist angesagt? (20)

Android Booting Sequence
Android Booting SequenceAndroid Booting Sequence
Android Booting Sequence
 
Activity lifecycle
Activity lifecycleActivity lifecycle
Activity lifecycle
 
Learning AOSP - Android Booting Process
Learning AOSP - Android Booting ProcessLearning AOSP - Android Booting Process
Learning AOSP - Android Booting Process
 
Permission in Android Security: Threats and solution
Permission in Android Security: Threats and solutionPermission in Android Security: Threats and solution
Permission in Android Security: Threats and solution
 
Embedded Android : System Development - Part II (Linux device drivers)
Embedded Android : System Development - Part II (Linux device drivers)Embedded Android : System Development - Part II (Linux device drivers)
Embedded Android : System Development - Part II (Linux device drivers)
 
Embedded Android Workshop
Embedded Android WorkshopEmbedded Android Workshop
Embedded Android Workshop
 
Android Storage - Vold
Android Storage - VoldAndroid Storage - Vold
Android Storage - Vold
 
Hacking Android OS
Hacking Android OSHacking Android OS
Hacking Android OS
 
Embedded Android : System Development - Part III (Audio / Video HAL)
Embedded Android : System Development - Part III (Audio / Video HAL)Embedded Android : System Development - Part III (Audio / Video HAL)
Embedded Android : System Development - Part III (Audio / Video HAL)
 
Multithreading in Android
Multithreading in AndroidMultithreading in Android
Multithreading in Android
 
Gpu presentation
Gpu presentationGpu presentation
Gpu presentation
 
Linux Porting
Linux PortingLinux Porting
Linux Porting
 
Automotive android
Automotive androidAutomotive android
Automotive android
 
Embedded Android : System Development - Part IV
Embedded Android : System Development - Part IVEmbedded Android : System Development - Part IV
Embedded Android : System Development - Part IV
 
External memory
External memoryExternal memory
External memory
 
Learning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device DriverLearning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device Driver
 
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
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android Development
 
Camera2 API, SHIM, and HAL 3.2 in Android 5.1
Camera2 API, SHIM, and HAL 3.2 in Android 5.1Camera2 API, SHIM, and HAL 3.2 in Android 5.1
Camera2 API, SHIM, and HAL 3.2 in Android 5.1
 
Android crash debugging
Android crash debuggingAndroid crash debugging
Android crash debugging
 

Andere mochten auch

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 AndroidHuyen 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 ApplicationsHuyen 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 & OpenSLYoss 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 cameratianaphoto
 
Android media framework overview
Android media framework overviewAndroid media framework overview
Android media framework overviewJerrin 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 imagesChris Simmonds
 

Andere mochten auch (10)

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
 
Design and Concepts of Android Graphics
Design and Concepts of Android GraphicsDesign and Concepts of Android Graphics
Design and Concepts of Android Graphics
 
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
 

Ähnlich wie 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_qtmultimediakitonmobilegareth_stockwell
 
Inside Android's UI
Inside Android's UIInside Android's UI
Inside Android's UIOpersys inc.
 
Inside Android's UI / ABS 2013
Inside Android's UI / ABS 2013Inside Android's UI / ABS 2013
Inside Android's UI / ABS 2013Opersys 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 APIsBalwinder 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 AndroidSittiphol 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 IIISlide_N
 
Smedberg niklas bringing_aaa_graphics
Smedberg niklas bringing_aaa_graphicsSmedberg niklas bringing_aaa_graphics
Smedberg niklas bringing_aaa_graphicschangehee lee
 
AGDK tutorial step by step
AGDK tutorial step by stepAGDK tutorial step by step
AGDK tutorial step by stepJungsoo Nam
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and DevelopmentOpersys inc.
 
Camera2 API: Overview
Camera2 API: OverviewCamera2 API: Overview
Camera2 API: OverviewSuhyun Park
 

Ähnlich wie 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
 

Kürzlich hochgeladen

Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 

Kürzlich hochgeladen (20)

Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 

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