CameraXSource

public class CameraXSource extends Object
implements LifecycleOwner

Manages the camera in conjunction with an underlying Detector and DetectionTaskCallback. This receives preview frames from the camera at a specified rate, sending those frames to the detector as fast as it is able to process those frames.

This camera source is using CameraX APIs internally.

The following Android permission is required to use the camera:

  • android.permissions.CAMERA

Public Constructor Summary

CameraXSource(CameraSourceConfig cameraSourceConfig)
Create a CameraXSource with given CameraSourceConfig.
CameraXSource(CameraSourceConfig cameraSourceConfig, PreviewView previewView)
Create a CameraXSource with given CameraSourceConfig and a PreviewView for the preview frames to be displayed to the user.

Public Method Summary

void
close()
Closes the camera and releases the resources of the camera and underlying detector.
int
Size
getPreviewSize()
Returns the preview size that is currently in use by the underlying camera.
void
start()
Opens the camera and starts sending preview frames to the underlying detector.
void
stop()
Stops the camera and releases the resources of the camera.

Inherited Method Summary

Public Constructors

public CameraXSource (CameraSourceConfig cameraSourceConfig)

Create a CameraXSource with given CameraSourceConfig.

public CameraXSource (CameraSourceConfig cameraSourceConfig, PreviewView previewView)

Create a CameraXSource with given CameraSourceConfig and a PreviewView for the preview frames to be displayed to the user.

Public Methods

public void close ()

Closes the camera and releases the resources of the camera and underlying detector.

public int getCameraFacing ()

public Size getPreviewSize ()

Returns the preview size that is currently in use by the underlying camera. The result could be null if the PreviewView has not been started.

public void start ()

Opens the camera and starts sending preview frames to the underlying detector.

public void stop ()

Stops the camera and releases the resources of the camera.