14

What is Android CameraX?

There is a session about CameraX planned in Google I/O 2019. What is it? Is it a new framework API? Is it a new library? https://events.google.com/io/schedule/events/8d400240-f31f-4ac2-bfab-f8347ef3ab3e

Does it mean that Camera2 API is deprecated? https://github.com/googlesamples/android-Camera2Basic

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
Yuichi Araki
  • 3,438
  • 1
  • 19
  • 24
  • https://www.reddit.com/r/androiddev/comments/b6ec74/camerax_support_library_confirmed_in_the_google/ – Tim Apr 23 '19 at 11:03

3 Answers3

18

What is Android CameraX?

CameraX is a new Jetpack library that lets developers control a device's camera and focuses on compatibility across devices going back to API level 21 (Lollipop). It was announced at Google I/O 2019 and has a dedicated documentation page alongside an official sample.

Does it mean that Camera2 API is deprecated?

Camera2 API is not deprecated; in fact, it is the foundation that CameraX is built on. CameraX also provides a Camera2 interop API that lets developers extend their CameraX implementation with Camera2 code.

For more information, the official documentation is available at https://developer.android.com/camerax

Oscar Wahltinez
  • 1,155
  • 3
  • 12
  • 24
  • FYI: For camerax: The CameraX library is in alpha stage, as its API surfaces aren't yet finalized. We do not recommend using Alpha libraries in production. Libraries should strictly avoid depending on Alpha libraries in production, as their API surfaces may change in source- and binary-incompatible ways. https://developer.android.com/training/camerax – LiuWenbin_NO. Sep 13 '19 at 08:28
  • 3
    You said "CameraX also provides a Camera2 interop API", I am looking for the way to do that since a few hours.... Please could you provide a link to a documentation ? – Maxime Esprit Jul 24 '20 at 08:58
8

In Google IO 2019, Google added another powerful tool for camera development in Android development called CameraX as part of Jetpack

Few Features of CameraX

  • It is backwards compatible till Android 5.0 / Lollipop (API 21) and it works with at least 90% devices in the market.
  • Under the hood, it uses and leverages the Camera 2 APIs. It basically, provide the same consistency as Camera 1 API via Camera 2 Legacy layer and it fixed a lot of issues across the device.
  • It also has a lot of awesome advanced features like Portrait, HDR, Night mode etc (Provided your Device supports that).
  • CameraX has also introduced use cases which allow you to focus on the the task you need to get it done and not waste your time with specific devices. Few of them are Preview, Image Analysis, Image Capture.
  • CameraX doesn't have specific call/stop methods in onResume() and onPause() but it binds to the lifecycle of the View with the help of CameraX.bindToLifecycle()
  • The following is the few lists of known issues fixed with CameraX,

enter image description here

what more you can do with CameraX

  • You can also create Video Recorder App using CameraX
  • Add multiple extensions like Portrait Mode, HDR etc.
  • We can also use Image Analysis to perform Computer Vision, ML. So it implements Analyzer method to run on each and every frame.

To read more about CameraX refer here

for Getting Started with CameraX

Basi
  • 3,009
  • 23
  • 28
0

You can check the official doc:

CameraX is an addition to Android Jetpack that makes it easier to add camera capabilities to your app. The library provides a number of compatibility fixes and workarounds to help make the developer experience consistent across many devices.

You can use cameraX to interface with a device’s camera through an abstraction called a use case. The following use cases are currently available:

  • Preview: prepares a preview SurfaceTexture
  • Image analysis: provides CPU-accessible buffers for analysis, such as for machine learning
  • Image capture: captures and saves a photo

Use cases can be combined and active concurrently.

Just add the dependencies:

dependencies {
  // CameraX core library
  def camerax_version = "1.0.0-alpha01"
  implementation "androidx.camera:camera-core:$camerax_version"
  // If you want to use Camera2 extensions
  implementation "androidx.camera:camera-camera2:$camerax_version"
}

For information on how to use the CameraX library check here.

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841