Android CameraX – Extensions

Tram Ho

In this article, I will introduce a very important component in CameraX, which is Vendor Extensions .

1. Introduction

In recent phone introductions of Android phone manufacturers such as Samsung or Google and Huawei, you are no stranger to hegemony photography features. HDR , Bokeh , Night , Beauty , Auto . In addition to the hardware system including a set of conventional cameras, telephoto cameras, wide angle cameras or macro cameras, the built-in software also makes the images more magical.

In cooperation with some original equipment manufacturers (OEMs) such as LG and Samsung; Google has developed an extension feature for mobile cameras. CameraX offers a number of API extensions like Bokeh, HDR and some features implemented by each manufacturer specifically for their device.

Devices that support vendor extensions must meet the following conditions:

  • Effects must have support library from device manufacturer (OEM)
  • OEM library must be installed on current device
  • The OEM library reports the device that supports the extension
  • The device has the operating system version the library requires

2. Extension architecture

Extensions are separated from Camera2 core of CameraX. In the picture, the red arrow lines show the path when a user activates an extension feature (eg HDR)

3. Implementation

To use extensions, you must implement the support library:

To use the extension in CameraX, you must create the corresponding Extender object that suits your needs:

  • AutoImageCaptureExtender
  • BeautyImageCaptureExtender
  • BokehImageCaptureExtender
  • HdrImageCaptureExtender
  • NightImageCaptureExtender

To enable extension, use the enableExtension () method.

In the above code, I have created cameraSelector to take photos from the rear camera LENS_FACING_BACK and use the Bokeh effect when the device supports it. If you want to use other effects, you absolutely can with the Extender object I listed above.

Refer to https://developer.android.com/training/camerax/vendor-extensions

Share the news now

Source : Viblo