CameraWrapper
A high level implementation over CameraX that provides a streamlined API to interact with a hardware camera for preview, image analysis, image capture, and video recording.
NOTE: This class must be used from within the main thread.
Constructors
Functions
Cancels an ongoing autofocus request. Calls to this method are ignored if the camera is not initialized.
Gets the support information of the hardware camera, or null if is not available.
Returns the id of the opened camera, or null if not available.
Determines if the camera has been selected and initialized.
Selects and opens the best hardware camera candidate according to the supplied criteria, waiting for it to be available or claiming the resource if necessary.
Requests the camera to perform an autofocus in the region of interest. The autofocus won't work if the camera does not support autofocus modes.
Requests the camera to change the torch state. If the camera does not have a torch unit then the torch change will fail.
Initializes the start of the camera preview on screen and preview frames to consume.
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.
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.
Requests the camera to start the recording of a video, if there is already an ongoing video recording it will be stopped and discarded before starting the new video recording request.
Stops the camera preview, doing so stops the stream of preview frames and the ability to interact safely with the camera. Calling this method while the camera is not initialized has no effect.
Stops an ongoing video recording if any. The video recording contents are published to videoRecordings if the video was successful.
Requests the camera to take a picture.
Properties
Sets a custom supported focus mode to use by the camera. If the value is set while the camera isn’t initialized it will be applied to the camera settings once it is.
LiveData object that emits a boolean that shows if the camera is currently going through a focusing process from calling requestAutoFocus.
LiveData object that emits events and errors during the camera initialization and interaction.
LiveData object that emits the frames when the camera can process a request to take a picture.
LiveData object that emits the preview frames.
LiveData object to emit the status of the torch state, True for on and False for off.