CameraSelector

public final class CameraSelector
extends Object

java.lang.Object
   ↳ androidx.camera.core.CameraSelector


A set of requirements and priorities used to select a camera or return a filtered set of cameras.

Summary

Nested classes

class CameraSelector.Builder

Builder for a CameraSelector

Constants

int LENS_FACING_BACK

A camera on the device facing the opposite direction as the device's screen.

int LENS_FACING_FRONT

A camera on the device facing the same direction as the device's screen.

Fields

public static final CameraSelector DEFAULT_BACK_CAMERA

A static CameraSelector that selects the default back facing camera.

public static final CameraSelector DEFAULT_FRONT_CAMERA

A static CameraSelector that selects the default front facing camera.

Public methods

List<CameraInfo> filter(List<CameraInfo> cameraInfos)

Filters the input CameraInfos using the CameraFilters assigned to the selector.

Inherited methods

Constants

LENS_FACING_BACK

public static final int LENS_FACING_BACK

A camera on the device facing the opposite direction as the device's screen.

Constant Value: 1 (0x00000001)

LENS_FACING_FRONT

public static final int LENS_FACING_FRONT

A camera on the device facing the same direction as the device's screen.

Constant Value: 0 (0x00000000)

Fields

DEFAULT_BACK_CAMERA

public static final CameraSelector DEFAULT_BACK_CAMERA

A static CameraSelector that selects the default back facing camera.

DEFAULT_FRONT_CAMERA

public static final CameraSelector DEFAULT_FRONT_CAMERA

A static CameraSelector that selects the default front facing camera.

Public methods

filter

public List<CameraInfo> filter (List<CameraInfo> cameraInfos)

Filters the input CameraInfos using the CameraFilters assigned to the selector.

If the CameraFilters assigned to this selector produce a camera info that is not part of the input list, the output list will be empty.

An example use case for using this function is when you want to get all CameraInfos for all available back facing cameras.

 eg.
 CameraInfo defaultBackCameraInfo = null;
 CameraSelector selector = new CameraSelector.Builder()
      .requireLensFacing(LENS_FACING_BACK).build();
 List<CameraInfo> cameraInfos = selector.filter(cameraProvider.getAvailableCameraInfos());
 
 

Parameters
cameraInfos List: The camera infos list being filtered.

Returns
List<CameraInfo> The remaining list of camera infos.

Throws
UnsupportedOperationException If the CameraFilters assigned to the selector try to modify the input camera infos list.