This website or its third-party tools use cookies which are necessary to its functioning and required to improve your experience. By clicking the consent button, you agree to allow the site to use, collect and/or store cookies.
Please click the consent button to view this website.
I accept
Deny cookies Go Back

Mobile app tutorials

  • Home
  • About
  • Contact
  • Login
You are here: Home / Kotlin Camera2 API / Kotlin Android Camera2 API

November 19, 2017 by nigel

Kotlin Android Camera2 API

 
The Kotlin Android Camera2 API introduction describes how to implement the Android Camera2 API using the Kotlin programming language.

Each episode will be released on a weekly basis. Though there is the option of getting access to all the episodes straight away by buying the series.

Create TextureView

Kotlin Android Camera2 API TextureView
The first Kotlin on Android episode introduces the initial code base that is provided from git.
And then moves on to adding a TextureView to the Android fragment. A TextView SurfaceTextureListener does need to be implemented. Which will notify when the surface texture is available.

Camera2 EasyPermissions

kotlin android camera2 api easypermissions
Before the Android Camera2 API can be accessed, permission must be granted by the user.
From Android 6.0 (Marshmellow) and onwards, Android runtime permissions must be implemented.
To simplify this process, the EasyPermissions libary is used.
This Kotlin on Android tutorial describes how to install and use the EasyPermission library.
Resulting in the user being requested to grant permission for the camera.

Get Id for Camera Device

kotlin android camera2 api device id
One of the first steps of using the Android camera2 API is to decide which camera device to connect to.
This will normally either be the forward or rear facing lens. The Android camera2 API provides ids for both of these lenses.
In this Kotlin on Android tutorial we will describe how to get the camera device id for a particular facing lens. And how the CameraManager & CameraCharateristics are used to achieve this.

Connect to Camera Device

kotlin android camera2 api connect open device
Once the camera device id has been found, a connection to the camera device can be requested.
If successful, a camera device will be created and opened.
In this Kotlin on Android tutorial we will describe how to use the camera manager and camera device state callbacks to open a connection to the camera device.

Display Rear Camera

kotlin android camera2 api rear camera
Upon successfully opening a connection to a camera device, camera capture requests can then be made.
First, a camera capture session must be created. A list of surfaces must be provided as targets for capturing the camera data to. And in this Kotlin on Android tutorial, we will be using the TextureView surface to capture images from the rear camera.
To start the preview capture, a request must be made on the camera capture session.

Display front Camera (Premium)

kotlin android camera2 api front camera
In this Kotlin on Android tutorial we will describe the steps for switching between the forward and rear facing camera lenses.
An item in the navigation drawer will be added. This will be used for switching between the camera lenses.
For closing one camera and starting another there is a defined process flow. And in this Kotlin on Android tutorial we will clearly describes the steps involved.

Using Preview with SurfaceView (Premium)

kotlin android camera2 api surfaceview
From Android 7.0 and later it is recommended to use the SurfaceView instead of the TextureView.
And in this Kotlin on Android tutorial, we will describe how to add a SurfaceView target to the camera device.
Note there is an issue when using the navigation drawer with a SurfaceView. Where the SurfaceView get drawn over the navigation drawer.
This Kotlin on Android tutorial will also address this issue and describe the steps to bring the navigation drawer back on top of the screen.

Print Friendly

Filed Under: Kotlin Camera2 API Tagged With: Android, Camera Capture, Camera Device, Kotlin, Kotlin Camera2 Api

  • Facebook
  • Google+
  • Twitter
  • YouTube




Recent Forum Topics

  • Kotlin Fragments
  • Kotlin Camera2 API
  • HTTP Image Libraries

Recent Posts

  • Installing and running flutter
  • Kotlin Camera2 API MediaRecorder
  • Flutter IntelliJ Tips for Beginners
  • Migrating Fragments to Jetpack Navigation
  • Flutter TabBar

Recent Posts

  • Installing and running flutter
  • Kotlin Camera2 API MediaRecorder
  • Flutter IntelliJ Tips for Beginners
  • Migrating Fragments to Jetpack Navigation
  • Flutter TabBar

Search Form

  • Facebook
  • GitHub
  • Google+
  • Twitter
  • YouTube

© 2021 - WWW.MOBAPPTUTS.COM