SlideShare a Scribd company logo
CameraX, meets ML
Wonyoung Choi
Singapore Tourism Board

@TORU_0239
GDG DevFest Songdo 2019, at 30 Nov, 2019
I am…
Wonyoung Choi, a.k.a Toru

Android Advocate,

Singapore Tourism Board
@TORU_0239

GitHub: TORU239
CameraX
Introduction
• Announced in Google I/O 2019
• Jetpack Support Library
• Easier Approach to leverage Camera2
Consolidation
• Lifecycle-aware component
• Backward compatibility till L
• Use-case based approaches
• Resolving device-compatibility issues
Use Cases
• Preview
• Image Analysis
• Image Capture
Preview
<TextureView
android:id="@+id/view_finder"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
val previewConfig = PreviewConfig.Builder().apply {
setLensFacing(CameraX.LensFacing.BACK)
setTargetAspectRatio(AspectRatio.RATIO_4_3)
setTargetRotation(viewFinder.display.rotation)
}.build()
val previewConfig = PreviewConfig.Builder().apply {
setLensFacing(CameraX.LensFacing.BACK)
setTargetResolution(
Size(metrics.widthPixels,metrics.heightPixels)
)
setTargetRotation(viewFinder.display.rotation)
}.build()
val previewConfig = PreviewConfig.Builder().apply {
setLensFacing(CameraX.LensFacing.BACK)
setTargetAspectRatio(AspectRatio.RATIO_4_3)
setTargetResolution(
Size(metrics.widthPixels,metrics.heightPixels)
)
setTargetRotation(viewFinder.display.rotation)
}.build()
How about this?
val previewConfig = PreviewConfig.Builder().apply {
setLensFacing(CameraX.LensFacing.BACK)
setTargetAspectRatio(AspectRatio.RATIO_4_3)
setTargetResolution(
Size(metrics.widthPixels,metrics.heightPixels)
)
setTargetRotation(viewFinder.display.rotation)
}.build()
Crash!
Image Analysis
val imageAnalysisConfig = ImageAnalysisConfig.Builder().apply {
setLensFacing(CameraX.LensFacing.BACK)
setImageReaderMode(ImageAnalysis.ImageReaderMode
.ACQUIRE_LATEST_IMAGE)
setTargetRotation(viewFinder.display.rotation)
}.build()
val executor = Executors.newSingleThreadExecutor()
imageAnalyzer = ImageAnalysis(imageAnalysisConfig).apply {
setAnalyzer(
executor,
ImageAnalysis.Analyzer { image, rotationDegrees ->
// Do whatever you want.
})
}
Analyzer
• Interface for analysing images
• Implement analyze() for use
Image Proxy
• Analogous interface as Image
• Informations on image contained
Image Capture
val captureConfig = ImageCaptureConfig.Builder().apply {
setLensFacing(CameraX.LensFacing.BACK)
setCaptureMode(ImageCapture.CaptureMode.MIN_LATENCY)
setTargetResolution(Size(metrics.widthPixels, metrics.heightPixels))
setTargetRotation(viewFinder.display.rotation)
}
.build()
val imageCapture = ImageCapture(captureConfig)
Binding to lifecycle
• Only few codes required to bind.
CameraX.bindToLifecycle(
viewLifecycleOwner,
preview,
imageCapture,
imageAnalyzer
)
CameraX.unbindAll()
Interact
• Taking picture by an api
imageCapture.takePicture(,,,)
Use Cases
• Preview
• Image Analysis
• Image Capture
Beware
• Alpha Stage
• Particular things on particular devices
ML Kit
What is ML Kit?
• Google’s Machine Learning SDK for Mobile
• Approachable by few lines of code
Vision API
• Image Labelling
• Text Recognition
• Barcode Scanning
• Face Detection
• Landmark Detection
• Object Detection and Tracking
• AutoML Vision Edge
Image Labelling
• Recognising image without additional metadata
• Deriving entities with confidence level
Image Labelling
On-Device Model
Cloud Model
ML Kit
Camera
Image Labelling
On-Device Model
Cloud Model
ML Kit
Camera
400+ categories
10000+ categories
Beware
• Beta Stage
• Changes on API
AutoML
Introduction
• Suites of ML Products
• Fitted to environment with less expertises
AutoML Vision Edge
• Custom Image Labelling
• Narrower domain of concepts
AutoML Vision Edge
val firebaseAutoMLLocalModel = FirebaseAutoMLLocalModel.Builder()
.setAssetFilePath("manifest.json")
.build()
val labeller = FirebaseVision.getInstance()
.getOnDeviceAutoMLImageLabeler(
FirebaseVisionOnDeviceAutoMLImageLabelerOptions
.Builder(firebaseAutoMLLocalModel)
.setConfidenceThreshold(0.5F)
.build()
)
labeller.processImage(image)
.addOnSuccessListener { labels ->
// Task completed successfully
// ...
}
.addOnFailureListener { e ->
// Task failed with an exception
// ...
}
val image: FirebaseVisionImage
try {
image = FirebaseVisionImage.fromFilePath(context, uri)
} catch (e: IOException) {
e.printStackTrace()
}
val image = FirebaseVisionImage.fromBitmap(bitmap)
dependencies {
// ...
implementation 'com.google.firebase:firebase-ml-vision:24.0.1'
implementation 'com.google.firebase:firebase-ml-vision-image-label-model:19.0.0'
}
apply plugin: 'com.google.gms.google-services'
build.gradle in app level
android {
...
aaptOptions {
noCompress "tflite"
}
}
Don’t forget to put this code!
Sample Project -

Food Scanner!
Further Studies
New capabilities
• Tap to focus
• Zoom
• Device Rotation Info
• Flash Availability
• And so on!
Extensions
• Night mode
• HDR
• Few lines of code required only!
Thank You!
Wonyoung Choi

@TORU_0239

More Related Content

Similar to CameraX, MLKit and AutoML at DevFest Songdo 2019

Use Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDEUse Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDEBenjamin Cabé
 
Extending Appcelerator Titanium Mobile through Native Modules
Extending Appcelerator Titanium Mobile through Native ModulesExtending Appcelerator Titanium Mobile through Native Modules
Extending Appcelerator Titanium Mobile through Native Modules
omorandi
 
Create an image classifier with azure custom vision net sdk
Create an image classifier with azure custom vision net sdkCreate an image classifier with azure custom vision net sdk
Create an image classifier with azure custom vision net sdk
Luis Beltran
 
Modern android development
Modern android developmentModern android development
Modern android development
Khiem-Kim Ho Xuan
 
Developing maintainable Cordova applications
Developing maintainable Cordova applicationsDeveloping maintainable Cordova applications
Developing maintainable Cordova applications
Ivano Malavolta
 
Introduction to Google Cloud Platform and APIs
Introduction to Google Cloud Platform and APIsIntroduction to Google Cloud Platform and APIs
Introduction to Google Cloud Platform and APIs
GDSCSoton
 
Philipp Nagele (Wikitude) Wikitude SDK Tutorial
Philipp Nagele (Wikitude) Wikitude SDK Tutorial Philipp Nagele (Wikitude) Wikitude SDK Tutorial
Philipp Nagele (Wikitude) Wikitude SDK Tutorial
AugmentedWorldExpo
 
Developing an object detector solution with Azure Custom Vision .NET SDK
Developing an object detector solution with Azure Custom Vision .NET SDKDeveloping an object detector solution with Azure Custom Vision .NET SDK
Developing an object detector solution with Azure Custom Vision .NET SDK
Luis Beltran
 
Android architecture
Android architecture Android architecture
Android architecture
Trong-An Bui
 
Azure functions
Azure functionsAzure functions
Azure functions
명신 김
 
The Role of Python in SPAs (Single-Page Applications)
The Role of Python in SPAs (Single-Page Applications)The Role of Python in SPAs (Single-Page Applications)
The Role of Python in SPAs (Single-Page Applications)
David Gibbons
 
angularJs Workshop
angularJs WorkshopangularJs Workshop
angularJs Workshop
Ran Wahle
 
JavaScript Framework Smackdown
JavaScript Framework SmackdownJavaScript Framework Smackdown
JavaScript Framework Smackdown
meghantaylor
 
Infinum Android Talks #14 - Data binding to the rescue... or not (?) by Krist...
Infinum Android Talks #14 - Data binding to the rescue... or not (?) by Krist...Infinum Android Talks #14 - Data binding to the rescue... or not (?) by Krist...
Infinum Android Talks #14 - Data binding to the rescue... or not (?) by Krist...
Infinum
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
Iván Fernández Perea
 
Exploring Google (Cloud) APIs with Python & JavaScript
Exploring Google (Cloud) APIs with Python & JavaScriptExploring Google (Cloud) APIs with Python & JavaScript
Exploring Google (Cloud) APIs with Python & JavaScript
wesley chun
 
Building an Android app with Jetpack Compose and Firebase
Building an Android app with Jetpack Compose and FirebaseBuilding an Android app with Jetpack Compose and Firebase
Building an Android app with Jetpack Compose and Firebase
Marina Coelho
 
Android Data Binding
Android Data BindingAndroid Data Binding
Android Data Binding
Oswald Campesato
 
Angularjs
AngularjsAngularjs
Angularjs
sanjay joshi
 
Philipp Nagele (CTO, Wikitude) An Insider Deep-Dive into the Wikitude SDK
Philipp Nagele (CTO, Wikitude) An Insider Deep-Dive into the Wikitude SDK Philipp Nagele (CTO, Wikitude) An Insider Deep-Dive into the Wikitude SDK
Philipp Nagele (CTO, Wikitude) An Insider Deep-Dive into the Wikitude SDK
AugmentedWorldExpo
 

Similar to CameraX, MLKit and AutoML at DevFest Songdo 2019 (20)

Use Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDEUse Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDE
 
Extending Appcelerator Titanium Mobile through Native Modules
Extending Appcelerator Titanium Mobile through Native ModulesExtending Appcelerator Titanium Mobile through Native Modules
Extending Appcelerator Titanium Mobile through Native Modules
 
Create an image classifier with azure custom vision net sdk
Create an image classifier with azure custom vision net sdkCreate an image classifier with azure custom vision net sdk
Create an image classifier with azure custom vision net sdk
 
Modern android development
Modern android developmentModern android development
Modern android development
 
Developing maintainable Cordova applications
Developing maintainable Cordova applicationsDeveloping maintainable Cordova applications
Developing maintainable Cordova applications
 
Introduction to Google Cloud Platform and APIs
Introduction to Google Cloud Platform and APIsIntroduction to Google Cloud Platform and APIs
Introduction to Google Cloud Platform and APIs
 
Philipp Nagele (Wikitude) Wikitude SDK Tutorial
Philipp Nagele (Wikitude) Wikitude SDK Tutorial Philipp Nagele (Wikitude) Wikitude SDK Tutorial
Philipp Nagele (Wikitude) Wikitude SDK Tutorial
 
Developing an object detector solution with Azure Custom Vision .NET SDK
Developing an object detector solution with Azure Custom Vision .NET SDKDeveloping an object detector solution with Azure Custom Vision .NET SDK
Developing an object detector solution with Azure Custom Vision .NET SDK
 
Android architecture
Android architecture Android architecture
Android architecture
 
Azure functions
Azure functionsAzure functions
Azure functions
 
The Role of Python in SPAs (Single-Page Applications)
The Role of Python in SPAs (Single-Page Applications)The Role of Python in SPAs (Single-Page Applications)
The Role of Python in SPAs (Single-Page Applications)
 
angularJs Workshop
angularJs WorkshopangularJs Workshop
angularJs Workshop
 
JavaScript Framework Smackdown
JavaScript Framework SmackdownJavaScript Framework Smackdown
JavaScript Framework Smackdown
 
Infinum Android Talks #14 - Data binding to the rescue... or not (?) by Krist...
Infinum Android Talks #14 - Data binding to the rescue... or not (?) by Krist...Infinum Android Talks #14 - Data binding to the rescue... or not (?) by Krist...
Infinum Android Talks #14 - Data binding to the rescue... or not (?) by Krist...
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
 
Exploring Google (Cloud) APIs with Python & JavaScript
Exploring Google (Cloud) APIs with Python & JavaScriptExploring Google (Cloud) APIs with Python & JavaScript
Exploring Google (Cloud) APIs with Python & JavaScript
 
Building an Android app with Jetpack Compose and Firebase
Building an Android app with Jetpack Compose and FirebaseBuilding an Android app with Jetpack Compose and Firebase
Building an Android app with Jetpack Compose and Firebase
 
Android Data Binding
Android Data BindingAndroid Data Binding
Android Data Binding
 
Angularjs
AngularjsAngularjs
Angularjs
 
Philipp Nagele (CTO, Wikitude) An Insider Deep-Dive into the Wikitude SDK
Philipp Nagele (CTO, Wikitude) An Insider Deep-Dive into the Wikitude SDK Philipp Nagele (CTO, Wikitude) An Insider Deep-Dive into the Wikitude SDK
Philipp Nagele (CTO, Wikitude) An Insider Deep-Dive into the Wikitude SDK
 

More from Toru Wonyoung Choi

Glancing essential features of Dart, before stepping into Flutter
Glancing essential features of Dart, before stepping into FlutterGlancing essential features of Dart, before stepping into Flutter
Glancing essential features of Dart, before stepping into Flutter
Toru Wonyoung Choi
 
The use case of a scalable architecture
The use case of a scalable architectureThe use case of a scalable architecture
The use case of a scalable architecture
Toru Wonyoung Choi
 
Jetpack, with new features in 2021 GDG Georgetown IO Extended
Jetpack, with new features in 2021 GDG Georgetown IO ExtendedJetpack, with new features in 2021 GDG Georgetown IO Extended
Jetpack, with new features in 2021 GDG Georgetown IO Extended
Toru Wonyoung Choi
 
Building an app with Google's new suites
Building an app with Google's new suitesBuilding an app with Google's new suites
Building an app with Google's new suites
Toru Wonyoung Choi
 
datastore_devfest2020_incheon
datastore_devfest2020_incheondatastore_devfest2020_incheon
datastore_devfest2020_incheon
Toru Wonyoung Choi
 
Slide_Concat_adapter_july_2020
Slide_Concat_adapter_july_2020Slide_Concat_adapter_july_2020
Slide_Concat_adapter_july_2020
Toru Wonyoung Choi
 
activity_and_fragment_may_2020_lakopi
activity_and_fragment_may_2020_lakopiactivity_and_fragment_may_2020_lakopi
activity_and_fragment_may_2020_lakopi
Toru Wonyoung Choi
 
Slide_For_GDGKL_devfest_2019
Slide_For_GDGKL_devfest_2019Slide_For_GDGKL_devfest_2019
Slide_For_GDGKL_devfest_2019
Toru Wonyoung Choi
 

More from Toru Wonyoung Choi (8)

Glancing essential features of Dart, before stepping into Flutter
Glancing essential features of Dart, before stepping into FlutterGlancing essential features of Dart, before stepping into Flutter
Glancing essential features of Dart, before stepping into Flutter
 
The use case of a scalable architecture
The use case of a scalable architectureThe use case of a scalable architecture
The use case of a scalable architecture
 
Jetpack, with new features in 2021 GDG Georgetown IO Extended
Jetpack, with new features in 2021 GDG Georgetown IO ExtendedJetpack, with new features in 2021 GDG Georgetown IO Extended
Jetpack, with new features in 2021 GDG Georgetown IO Extended
 
Building an app with Google's new suites
Building an app with Google's new suitesBuilding an app with Google's new suites
Building an app with Google's new suites
 
datastore_devfest2020_incheon
datastore_devfest2020_incheondatastore_devfest2020_incheon
datastore_devfest2020_incheon
 
Slide_Concat_adapter_july_2020
Slide_Concat_adapter_july_2020Slide_Concat_adapter_july_2020
Slide_Concat_adapter_july_2020
 
activity_and_fragment_may_2020_lakopi
activity_and_fragment_may_2020_lakopiactivity_and_fragment_may_2020_lakopi
activity_and_fragment_may_2020_lakopi
 
Slide_For_GDGKL_devfest_2019
Slide_For_GDGKL_devfest_2019Slide_For_GDGKL_devfest_2019
Slide_For_GDGKL_devfest_2019
 

CameraX, MLKit and AutoML at DevFest Songdo 2019