CameraX: Getting Started
Learn how to create a camera app with the recently announced CameraX API for Android, which allows you to easily implement previews and real-time image analysis. By Aldo Olivares.
Who is this for?
This course is intended for Advanced Android developers who are interested in migrating from the old Camera2 APIs. This course expects you to be familiar with Android Studio, Android Development with Kotlin and to have experience with file management and runtime permissions. Familiarity with the Camera2 API is recommended but not required.
Covered concepts
- Adding permissions to the Android manifest
- Requesting runtime permissions for the camera.
- Preview use case with a TextureView
- Image Capture use case
- Image Analysis use case
Part 1: Work with CameraX
Learn what CameraX is and how it makes your app development easier by providing an easy to use API that works consistently across different devices with different manufacturers.
In this episode, you'll add CameraX dependencies and learn how to request permissions at runtime.
TextureView allows you to display a preview. Learn how to configure your TextureView to listen for changes in your device's orientation.
In this episode, learn how to display a preview of the picture you will take by creating a preview use case.
Learn how to give your users the power of choosing which camera they want to use to take a picture: front or back.
A camera app is only useful if it can take pictures. Learn how to take pictures with the camera and save them to local storage.
Learn how to configure the flash to turn it on or off according to the user's actions.
Part 2: Work with the Image Analyzer
Create a class that extends from ImageAnalysis.Analyzer and will display the average luminosity of a picture.
One of the most interesting features of CameraX is the ability to implement an image analyzer which allows you to analyze images using frameworks such as Firebase. Here, learn to create a Firebase project to use in your app.
Learn how to create a class that extends from ImageAnalysis.Analyzer and will display the raw value of your QR code.