SlideShare a Scribd company logo
1 of 21
Download to read offline
HUYEN TUE DAO
PROJECT
DATE BY
MAY 30, 2014
SAY CHEESE
BUILDING A CUSTOM CAMERA APPLICATION
360dp
wrap_content
ANDEVCON 2014
BUILDING A CUSTOM CAMERA APPLICATION
• Getting Started
• Setting up the Camera
• Taking pictures
• Camera settings
• “New” features in API 14
2
ABOUT ME
• Mobile developer: native Android and native iOS (personally I use
Android but no I do not have a “favorite”)
• Computer Engineering, University of MD, College Park
• Marylander living in Colorado
• Gamer (video, board, card, anything): currently Dota 2, Don’t
Starve, Kingdom Rush, 7 Wonders
3
TITLE
CUSTOM CAMERA CAPABILITY AND AVAILABILITY
What you want to do
What features
the API supports
Typical for Android development: Build.VERSION etc.
What features
the device camera has
Typical for Android development: use-feature and PackageManager
Specific to camera: querying support level from the Camera class
What you can do
THE CUSTOM CAMERA: THE MANIFEST
• Camera application hardware-driven so vital to
separate critical features from optional ones.
• Highly recommended to use specific <uses-feature>
to specify required features. Why?
• <uses-permission
android:name="android.permission.CAMERA" />!
- “This will automatically enforce the <uses-
feature> manifest element for all camera features.”
5
THE CUSTOM CAMERA: THE MANIFEST
• Just specifying the camera permission (without any
<uses-feature> specifications) means that a device
would require the following:
- a back-facing camera
- a front-facing camera
- auto-focus
- flash
• If you do not need any of the above, specify <uses-
feature> with android:required=false
6
TITLE
CAMERA CLASS AND INNER CLASSES
android.hardware.Camera*
Device camera client: setup + access point
Preview callback
Shutter callback
Picture taking callback
!
!
!
Auto Focus callback
Zoom listener
Face detection listener
Camera.CameraInfo
front or back, orientation,
shutter disable
Camera.Parameters
preview, picture output,
“photography stuff”:
features/settings dependent
on the device camera: flash
modes, color effects,
scene modes, white balance,
etc.
Camera.Area
“photography stuff”: focus and
metering, rectangular bounds + weight
Camera.Face
“face stuff”, bounds and feature (left
eye, right eye, mouth) coordinates for
a face identified with face detection,
confidence score
APK 14+: Data objects
Device camera information + settings
Camera.Size
width and height:
picture size, video size,
preview size
TITLE
THE CUSTOM CAMERA: CAMERA SETUP
Add a SurfaceView to your
layout for the camera preview.
Implement a
SurfaceHolder.Callback to
listen for #surfaceCreated,
#surfaceChanged, and
#surfaceDestroyed
Pass the callback to the
SurfaceHolder instance of
the SurfaceView.
Open a Camera instance:
Camera#open
Get the Camera.Parameters
and perform any initial setup.
After the preview surface has
been created, call
Camera#setPreviewDisplay
with the SurfaceHolder.
Start the preview:
Camera#startPreview.
wait for surface to be created
THE CUSTOM CAMERA: BASIC SETUP
• Things to note about setting up the camera preview:
- The surface is destroyed when the visibility of the
SurfaceView is set to View.INVISIBLE.
- Camera#release will stop the preview
- Camera#stopPreview nulls out callbacks, stops face
detection
- Camera#setPreviewDisplay should be called after the
surface is created. No error, just no preview.
- Any changes to the preview size must be between calls to
Camera#startPreview and Camera#stopPreview
9
THE CUSTOM CAMERA: PICTURE TAKING
• When the camera is set up, call
takePicture(ShutterCallback,
PictureCallback, PictureCallback,
PictureCallback)!
• PictureCallback parameters = 3 picture formats:
raw (uncompressed), postview, and JPEG.
- Raw and postview availability depends on device
- takePicture stops the camera preview so
Camera#startPreview should be called in/after
callbacks
10
THE CUSTOM CAMERA: CAMERA INFO
• CameraInfo: information about a particular device camera
- orientation: angle of rotation when facing the camera for the
camera image to match the natural orientation of the device
- facing: camera direction
- whether the shutter sound can be disabled
• Camera.getCameraInfo: camera IDs are indices 0 to n-1
• Use CameraInfo to swap between front and back
- Use PackageManager to check if a front camera exists unless
you have front camera as a requirement for device
- Close the current camera before swapping
11
TITLE
DEVICE ORIENTATION VS CAMERA ORIENTATION
Natural device orientation
Natural camera orientation
90° difference
THE CUSTOM CAMERA: ROTATION
• Some thoughts on rotation:
- Empirically, trying to work with camera/display
rotation and configuration changes sucks:
- Complicated.
- Orientation changes do not coordinate well
with camera orientation changes.
- Can change the activity orientation change
animation in API 18+).
13
THE CUSTOM CAMERA: CAMERA INFO
• Recommendation:
- Keep a fixed activity orientation.
- Call Camera#setDisplayOrientation to adjust
for CameraInfo.orientation.
- Use the OrientationEventListener to rotate
the UI.
- Does mean that your application thumbnail may
look sideways in the Recent Apps list.
14
THE CUSTOM CAMERA: CAMERA PARAMETERS
• Most of the fun stuff (settings and modes) is set in
Camera.Parameters.
- A couple of features (auto-focus and flash) have <uses-feature>
and PackageManager values.
- Most other features will provide support information via methods
in Camera.Parameters
- Example: getMinExposureCompensation returns 0 if exposure
compensation is unsupported
- Several getters provide lists of valid values for features or
modes that have different value ranges on different devices.
- Note that API level also factors: face detection and metering areas
are API 14+.
15
THE CUSTOM CAMERA: CAMERA PARAMETERS
• For the most part, Camera.Parameters can be changed while
preview started and will take effect immediately.
• For saving/restoring settings state, handy methods:
Camera.Parameters#flatten and
Camera.Parameters#unflatten
• Important:
- Always call Camera#getParameters, do not hold onto
Camera.Parameters instances
- To actually change parameters, set values on a
Camera.Parameters instance and call Camera#setParameters
16
THE CUSTOM CAMERA: CAMERA PARAMETERS
• Random tips and observations on Camera.Parameters:
- Auto-focus may cause the flash to activate depending on the
camera and its drivers.
- Setting a scene mode overrides other parameters so if camera
parameters have UI feedback may want to call
Camera#getParameters and update.
• Other common camera/photo features done through
Camera.Parameters:
- GPS coordinates and timestamps for geotagging photos.
- Image size and quality
- Note that image size and preview size are independent
17
THE CUSTOM CAMERA: WORKING WITH AREAS
• API 14: Camera.Area and metering areas and focus
areas
• Camera.Area: defines bounds within the viewfinder
for the camera to use in metering and focus
• Camera viewfinder/sensor has its own coordinate
system different from a View’s coordinate system.
• Otherwise, just like setting other camera
parameters
18
TITLE
VIEWFINDER COORDINATES VS VIEW COORDINATES
1000-1000
1000
-1000
Camera
(0,0)
H
W
View
THE CUSTOM CAMERA: FACE DETECTION
• API 14+
• Camera.Face, Camera.FaceDetectionListener,
Camera#startFaceDetection,
Camera#stopFaceDetection!
• Camera.Face camera coordinates of bounds of
face in viewfinder; maybe left eye, right eye, mouth
position; also confidence
• camera/sensor coordinates -> view coordinates
20
THANKS SO MUCH
FOR COMING!
!
QUESTIONS?
RANDOMLYTYPING.COM
HUYEN@RANDOMLYTYPING.COM
PRESENTER CONTACT
HUYEN TUE DAO
THINGS TO CHECK OUT
Standford Digital Image Processing Class
http://www.stanford.edu/class/ee368/Android/index.html
!
Android Design in Action
https://www.youtube.com/watch?v=OLSa7fErTAM

More Related Content

What's hot

Canon Camera With Flip Screen
Canon Camera With Flip ScreenCanon Camera With Flip Screen
Canon Camera With Flip ScreenBoomi Reviews
 
F8e30016551f18f4374655f76c414a90
F8e30016551f18f4374655f76c414a90F8e30016551f18f4374655f76c414a90
F8e30016551f18f4374655f76c414a90guestf2822a
 
Best canon camera for youtube
Best canon camera for youtubeBest canon camera for youtube
Best canon camera for youtubezertclub
 
Halloween horror nights photography
Halloween horror nights photographyHalloween horror nights photography
Halloween horror nights photographyDEEPAK S. SAWANT
 

What's hot (9)

CAMERA USE, BASICS
CAMERA USE, BASICSCAMERA USE, BASICS
CAMERA USE, BASICS
 
Digital Filming Equipment
Digital Filming Equipment Digital Filming Equipment
Digital Filming Equipment
 
Canon Camera With Flip Screen
Canon Camera With Flip ScreenCanon Camera With Flip Screen
Canon Camera With Flip Screen
 
Android Camera
Android CameraAndroid Camera
Android Camera
 
F8e30016551f18f4374655f76c414a90
F8e30016551f18f4374655f76c414a90F8e30016551f18f4374655f76c414a90
F8e30016551f18f4374655f76c414a90
 
Photography
PhotographyPhotography
Photography
 
Equipment
EquipmentEquipment
Equipment
 
Best canon camera for youtube
Best canon camera for youtubeBest canon camera for youtube
Best canon camera for youtube
 
Halloween horror nights photography
Halloween horror nights photographyHalloween horror nights photography
Halloween horror nights photography
 

Similar to AnDevCon 2014: Building a Custom Camera Application

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
 
Android 5.0 Camera2 APIs
Android 5.0 Camera2 APIsAndroid 5.0 Camera2 APIs
Android 5.0 Camera2 APIsBalwinder Kaur
 
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
 
SunEyes T Series Quick Installation Guide
SunEyes T Series Quick Installation GuideSunEyes T Series Quick Installation Guide
SunEyes T Series Quick Installation GuideSecurityCameraTalk
 
Multi-Modality Mobile Image Recognition Based on Thermal and Visual Cameras
Multi-Modality Mobile Image Recognition Based on Thermal and Visual CamerasMulti-Modality Mobile Image Recognition Based on Thermal and Visual Cameras
Multi-Modality Mobile Image Recognition Based on Thermal and Visual CamerasJui-Hsin (Larry) Lai
 
06.Programming Media on Windows Phone
06.Programming Media on Windows Phone06.Programming Media on Windows Phone
06.Programming Media on Windows PhoneNguyen Tuan
 
Photovoltaic Systems: System Design Tools
Photovoltaic Systems: System Design ToolsPhotovoltaic Systems: System Design Tools
Photovoltaic Systems: System Design ToolsGavin Harper
 
Camera manual auto
Camera manual autoCamera manual auto
Camera manual autoanzar coowar
 
Longshot Marksman Target Cameras Instruction Manual | Optics Trade
Longshot Marksman Target Cameras Instruction Manual | Optics TradeLongshot Marksman Target Cameras Instruction Manual | Optics Trade
Longshot Marksman Target Cameras Instruction Manual | Optics TradeOptics-Trade
 
Mopcon2017 - AppDevKit x CameraKit
Mopcon2017 - AppDevKit x CameraKitMopcon2017 - AppDevKit x CameraKit
Mopcon2017 - AppDevKit x CameraKitanistar sung
 
Sheldon Fernandes (Lucid VR): Real-time Calibration for Stereo Cameras Using ...
Sheldon Fernandes (Lucid VR): Real-time Calibration for Stereo Cameras Using ...Sheldon Fernandes (Lucid VR): Real-time Calibration for Stereo Cameras Using ...
Sheldon Fernandes (Lucid VR): Real-time Calibration for Stereo Cameras Using ...AugmentedWorldExpo
 
COSCUP 2017 FACE OFF
COSCUP 2017 FACE OFFCOSCUP 2017 FACE OFF
COSCUP 2017 FACE OFFPRADA Hsiung
 
Digital photography improvers course
Digital photography improvers courseDigital photography improvers course
Digital photography improvers courseMike Sleigh
 
"Computer-vision-based 360-degree Video Systems: Architectures, Algorithms an...
"Computer-vision-based 360-degree Video Systems: Architectures, Algorithms an..."Computer-vision-based 360-degree Video Systems: Architectures, Algorithms an...
"Computer-vision-based 360-degree Video Systems: Architectures, Algorithms an...Edge AI and Vision Alliance
 
Luis cataldi-ue4-vr-best-practices2
Luis cataldi-ue4-vr-best-practices2Luis cataldi-ue4-vr-best-practices2
Luis cataldi-ue4-vr-best-practices2Luis Cataldi
 
Camera2 API: Overview
Camera2 API: OverviewCamera2 API: Overview
Camera2 API: OverviewSuhyun Park
 

Similar to AnDevCon 2014: Building a Custom Camera Application (20)

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
 
Android 5.0 Camera2 APIs
Android 5.0 Camera2 APIsAndroid 5.0 Camera2 APIs
Android 5.0 Camera2 APIs
 
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)
 
SunEyes T Series Quick Installation Guide
SunEyes T Series Quick Installation GuideSunEyes T Series Quick Installation Guide
SunEyes T Series Quick Installation Guide
 
Multi-Modality Mobile Image Recognition Based on Thermal and Visual Cameras
Multi-Modality Mobile Image Recognition Based on Thermal and Visual CamerasMulti-Modality Mobile Image Recognition Based on Thermal and Visual Cameras
Multi-Modality Mobile Image Recognition Based on Thermal and Visual Cameras
 
06.Programming Media on Windows Phone
06.Programming Media on Windows Phone06.Programming Media on Windows Phone
06.Programming Media on Windows Phone
 
Photovoltaic Systems: System Design Tools
Photovoltaic Systems: System Design ToolsPhotovoltaic Systems: System Design Tools
Photovoltaic Systems: System Design Tools
 
Camera manual auto
Camera manual autoCamera manual auto
Camera manual auto
 
What is remote focus IP Camera
What is remote focus IP CameraWhat is remote focus IP Camera
What is remote focus IP Camera
 
DSLR Cameras
DSLR Cameras DSLR Cameras
DSLR Cameras
 
Longshot Marksman Target Cameras Instruction Manual | Optics Trade
Longshot Marksman Target Cameras Instruction Manual | Optics TradeLongshot Marksman Target Cameras Instruction Manual | Optics Trade
Longshot Marksman Target Cameras Instruction Manual | Optics Trade
 
Mopcon2017 - AppDevKit x CameraKit
Mopcon2017 - AppDevKit x CameraKitMopcon2017 - AppDevKit x CameraKit
Mopcon2017 - AppDevKit x CameraKit
 
Sheldon Fernandes (Lucid VR): Real-time Calibration for Stereo Cameras Using ...
Sheldon Fernandes (Lucid VR): Real-time Calibration for Stereo Cameras Using ...Sheldon Fernandes (Lucid VR): Real-time Calibration for Stereo Cameras Using ...
Sheldon Fernandes (Lucid VR): Real-time Calibration for Stereo Cameras Using ...
 
COSCUP 2017 FACE OFF
COSCUP 2017 FACE OFFCOSCUP 2017 FACE OFF
COSCUP 2017 FACE OFF
 
Digital photography improvers course
Digital photography improvers courseDigital photography improvers course
Digital photography improvers course
 
Photography lession 01
Photography  lession  01 Photography  lession  01
Photography lession 01
 
"Computer-vision-based 360-degree Video Systems: Architectures, Algorithms an...
"Computer-vision-based 360-degree Video Systems: Architectures, Algorithms an..."Computer-vision-based 360-degree Video Systems: Architectures, Algorithms an...
"Computer-vision-based 360-degree Video Systems: Architectures, Algorithms an...
 
Luis cataldi-ue4-vr-best-practices2
Luis cataldi-ue4-vr-best-practices2Luis cataldi-ue4-vr-best-practices2
Luis cataldi-ue4-vr-best-practices2
 
Camera2 API: Overview
Camera2 API: OverviewCamera2 API: Overview
Camera2 API: Overview
 
Szdalos
SzdalosSzdalos
Szdalos
 

Recently uploaded

MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfkalichargn70th171
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 

Recently uploaded (20)

MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
Odoo Development Company in India | Devintelle Consulting Service
Odoo Development Company in India | Devintelle Consulting ServiceOdoo Development Company in India | Devintelle Consulting Service
Odoo Development Company in India | Devintelle Consulting Service
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 

AnDevCon 2014: Building a Custom Camera Application

  • 1. HUYEN TUE DAO PROJECT DATE BY MAY 30, 2014 SAY CHEESE BUILDING A CUSTOM CAMERA APPLICATION 360dp wrap_content ANDEVCON 2014
  • 2. BUILDING A CUSTOM CAMERA APPLICATION • Getting Started • Setting up the Camera • Taking pictures • Camera settings • “New” features in API 14 2
  • 3. ABOUT ME • Mobile developer: native Android and native iOS (personally I use Android but no I do not have a “favorite”) • Computer Engineering, University of MD, College Park • Marylander living in Colorado • Gamer (video, board, card, anything): currently Dota 2, Don’t Starve, Kingdom Rush, 7 Wonders 3
  • 4. TITLE CUSTOM CAMERA CAPABILITY AND AVAILABILITY What you want to do What features the API supports Typical for Android development: Build.VERSION etc. What features the device camera has Typical for Android development: use-feature and PackageManager Specific to camera: querying support level from the Camera class What you can do
  • 5. THE CUSTOM CAMERA: THE MANIFEST • Camera application hardware-driven so vital to separate critical features from optional ones. • Highly recommended to use specific <uses-feature> to specify required features. Why? • <uses-permission android:name="android.permission.CAMERA" />! - “This will automatically enforce the <uses- feature> manifest element for all camera features.” 5
  • 6. THE CUSTOM CAMERA: THE MANIFEST • Just specifying the camera permission (without any <uses-feature> specifications) means that a device would require the following: - a back-facing camera - a front-facing camera - auto-focus - flash • If you do not need any of the above, specify <uses- feature> with android:required=false 6
  • 7. TITLE CAMERA CLASS AND INNER CLASSES android.hardware.Camera* Device camera client: setup + access point Preview callback Shutter callback Picture taking callback ! ! ! Auto Focus callback Zoom listener Face detection listener Camera.CameraInfo front or back, orientation, shutter disable Camera.Parameters preview, picture output, “photography stuff”: features/settings dependent on the device camera: flash modes, color effects, scene modes, white balance, etc. Camera.Area “photography stuff”: focus and metering, rectangular bounds + weight Camera.Face “face stuff”, bounds and feature (left eye, right eye, mouth) coordinates for a face identified with face detection, confidence score APK 14+: Data objects Device camera information + settings Camera.Size width and height: picture size, video size, preview size
  • 8. TITLE THE CUSTOM CAMERA: CAMERA SETUP Add a SurfaceView to your layout for the camera preview. Implement a SurfaceHolder.Callback to listen for #surfaceCreated, #surfaceChanged, and #surfaceDestroyed Pass the callback to the SurfaceHolder instance of the SurfaceView. Open a Camera instance: Camera#open Get the Camera.Parameters and perform any initial setup. After the preview surface has been created, call Camera#setPreviewDisplay with the SurfaceHolder. Start the preview: Camera#startPreview. wait for surface to be created
  • 9. THE CUSTOM CAMERA: BASIC SETUP • Things to note about setting up the camera preview: - The surface is destroyed when the visibility of the SurfaceView is set to View.INVISIBLE. - Camera#release will stop the preview - Camera#stopPreview nulls out callbacks, stops face detection - Camera#setPreviewDisplay should be called after the surface is created. No error, just no preview. - Any changes to the preview size must be between calls to Camera#startPreview and Camera#stopPreview 9
  • 10. THE CUSTOM CAMERA: PICTURE TAKING • When the camera is set up, call takePicture(ShutterCallback, PictureCallback, PictureCallback, PictureCallback)! • PictureCallback parameters = 3 picture formats: raw (uncompressed), postview, and JPEG. - Raw and postview availability depends on device - takePicture stops the camera preview so Camera#startPreview should be called in/after callbacks 10
  • 11. THE CUSTOM CAMERA: CAMERA INFO • CameraInfo: information about a particular device camera - orientation: angle of rotation when facing the camera for the camera image to match the natural orientation of the device - facing: camera direction - whether the shutter sound can be disabled • Camera.getCameraInfo: camera IDs are indices 0 to n-1 • Use CameraInfo to swap between front and back - Use PackageManager to check if a front camera exists unless you have front camera as a requirement for device - Close the current camera before swapping 11
  • 12. TITLE DEVICE ORIENTATION VS CAMERA ORIENTATION Natural device orientation Natural camera orientation 90° difference
  • 13. THE CUSTOM CAMERA: ROTATION • Some thoughts on rotation: - Empirically, trying to work with camera/display rotation and configuration changes sucks: - Complicated. - Orientation changes do not coordinate well with camera orientation changes. - Can change the activity orientation change animation in API 18+). 13
  • 14. THE CUSTOM CAMERA: CAMERA INFO • Recommendation: - Keep a fixed activity orientation. - Call Camera#setDisplayOrientation to adjust for CameraInfo.orientation. - Use the OrientationEventListener to rotate the UI. - Does mean that your application thumbnail may look sideways in the Recent Apps list. 14
  • 15. THE CUSTOM CAMERA: CAMERA PARAMETERS • Most of the fun stuff (settings and modes) is set in Camera.Parameters. - A couple of features (auto-focus and flash) have <uses-feature> and PackageManager values. - Most other features will provide support information via methods in Camera.Parameters - Example: getMinExposureCompensation returns 0 if exposure compensation is unsupported - Several getters provide lists of valid values for features or modes that have different value ranges on different devices. - Note that API level also factors: face detection and metering areas are API 14+. 15
  • 16. THE CUSTOM CAMERA: CAMERA PARAMETERS • For the most part, Camera.Parameters can be changed while preview started and will take effect immediately. • For saving/restoring settings state, handy methods: Camera.Parameters#flatten and Camera.Parameters#unflatten • Important: - Always call Camera#getParameters, do not hold onto Camera.Parameters instances - To actually change parameters, set values on a Camera.Parameters instance and call Camera#setParameters 16
  • 17. THE CUSTOM CAMERA: CAMERA PARAMETERS • Random tips and observations on Camera.Parameters: - Auto-focus may cause the flash to activate depending on the camera and its drivers. - Setting a scene mode overrides other parameters so if camera parameters have UI feedback may want to call Camera#getParameters and update. • Other common camera/photo features done through Camera.Parameters: - GPS coordinates and timestamps for geotagging photos. - Image size and quality - Note that image size and preview size are independent 17
  • 18. THE CUSTOM CAMERA: WORKING WITH AREAS • API 14: Camera.Area and metering areas and focus areas • Camera.Area: defines bounds within the viewfinder for the camera to use in metering and focus • Camera viewfinder/sensor has its own coordinate system different from a View’s coordinate system. • Otherwise, just like setting other camera parameters 18
  • 19. TITLE VIEWFINDER COORDINATES VS VIEW COORDINATES 1000-1000 1000 -1000 Camera (0,0) H W View
  • 20. THE CUSTOM CAMERA: FACE DETECTION • API 14+ • Camera.Face, Camera.FaceDetectionListener, Camera#startFaceDetection, Camera#stopFaceDetection! • Camera.Face camera coordinates of bounds of face in viewfinder; maybe left eye, right eye, mouth position; also confidence • camera/sensor coordinates -> view coordinates 20
  • 21. THANKS SO MUCH FOR COMING! ! QUESTIONS? RANDOMLYTYPING.COM HUYEN@RANDOMLYTYPING.COM PRESENTER CONTACT HUYEN TUE DAO THINGS TO CHECK OUT Standford Digital Image Processing Class http://www.stanford.edu/class/ee368/Android/index.html ! Android Design in Action https://www.youtube.com/watch?v=OLSa7fErTAM