startPreview

open override fun startPreview(surfaceProvider: Preview.SurfaceProvider, requireTakePictureCapability: Boolean)

Initializes the start of the camera preview on screen and preview frames to consume, the surfaceProvider must supply a valid surface when requested and it is responsible for managing the lifecycle of the surface.

If requireTakePictureCapability is requested, the camera will be configured to allow requests to take manual frames at the expense of performance and the ability to generate images for analysis with a higher resolution than 1080p on supported devices. If it is not requested and the capability is needed later, the camera must be re-initialized.

Parameters

surfaceProvider

The provider of the surface where the preview will send frames to display, it must supply a valid surface when requested.

requireTakePictureCapability

Determines whether manual picture-taking capabilities are enabled or disabled.

See also


open override fun startPreview(surfaceHolder: SurfaceHolder, requireTakePictureCapability: Boolean)

Deprecated

Use startPreview(Preview.SurfaceProvider) instead, this method will not be supported in future versions.

Initializes the start of the camera preview on screen and preview frames to consume, if the holders' underlying surface is null or invalid it will wait for it to be ready first.

If requireTakePictureCapability is requested, the camera will be configured to allow requests to take manual frames at the expense of performance and the ability to generate images for analysis with a higher resolution than 1080p on supported devices. If it is not requested and the capability is needed later, the camera must be re-initialized.

Parameters

surfaceHolder

The holder of the surface where the preview will send frames to display on screen.

requireTakePictureCapability

Determines whether manual picture-taking capabilities are enabled or disabled.


open override fun startPreview(surface: Surface, requireTakePictureCapability: Boolean)

Deprecated

Use startPreview(Preview.SurfaceProvider) instead, this method will not be supported in future versions.

Initializes the start of the camera preview on screen and preview frames to consume.

If requireTakePictureCapability is requested, the camera will be configured to allow requests to take manual frames at the expense of performance and the ability to generate images for analysis with a higher resolution than 1080p on supported devices. If it is not requested and the capability is needed later, the camera must be re-initialized.

Events emitted:

NOTE: the surface must be valid, if not the preview initialization will abort.

Parameters

surface

The surface where the preview will send frames to display on screen.

requireTakePictureCapability

Determines whether manual picture-taking capabilities are enabled or disabled.