Unit |
clearImageAnalysisAnalyzer()
Removes a previously set analyzer.
This will stop data from streaming to the ImageAnalysis .
|
ListenableFuture<Void!> |
enableTorch(torchEnabled: Boolean)
Enable the torch or disable the torch.
No-ops if the camera is not ready. The ListenableFuture completes successfully in this case.
|
CameraSelector |
getCameraSelector()
Gets the CameraSelector .
The default value isCameraSelector#DEFAULT_BACK_CAMERA .
|
Int |
getImageAnalysisBackpressureStrategy()
Returns the mode with which images are acquired.
If not set, it defaults to ImageAnalysis#STRATEGY_KEEP_ONLY_LATEST .
|
Int |
getImageAnalysisImageQueueDepth()
Gets the image queue depth of ImageAnalysis .
|
Int |
getImageCaptureFlashMode()
Gets the flash mode for ImageCapture .
|
ListenableFuture<Void!> |
getInitializationFuture()
Gets a ListenableFuture that completes when camera initialization completes.
This future may fail with an InitializationException and associated cause that can be retrieved by ). The cause will be a
|
LiveData<Int!> |
getTorchState()
Returns a LiveData of current TorchState .
The torch can be turned on and off via enableTorch(boolean) which will trigger the change event to the returned LiveData .
|
LiveData<ZoomState!> |
getZoomState()
Returns a LiveData of ZoomState .
The LiveData will be updated whenever the set zoom state has been changed. This can occur when the application updates the zoom via setZoomRatio(float) or setLinearZoom(float) . The zoom state can also change anytime a camera starts up, for example when setCameraSelector is called.
|
Boolean |
hasCamera(@NonNull cameraSelector: CameraSelector)
Checks if the given CameraSelector can be resolved to a camera.
Use this method to check if the device has the given camera.
Only call this method after camera is initialized. e.g. after the ListenableFuture from getInitializationFuture() is finished. Calling it prematurely throws IllegalStateException . Example:
<code>
controller.getInitializationFuture().addListener(() -> {
if (controller.hasCamera(cameraSelector)) {
controller.setCameraSelector(cameraSelector);
} else {
// Update UI if the camera is not available.
}
// Attach PreviewView after we know the camera is available.
previewView.setController(controller);
}, ContextCompat.getMainExecutor(requireContext()));
</code>
|
Boolean |
isImageAnalysisEnabled()
Checks if ImageAnalysis is enabled.
|
Boolean |
isImageCaptureEnabled()
Checks if ImageCapture is enabled.
ImageCapture is enabled by default. It has to be enabled before #takePicture can be called.
|
Boolean |
isPinchToZoomEnabled()
Returns whether pinch-to-zoom is enabled.
By default pinch-to-zoom is enabled.
|
Boolean |
isRecording()
Returns whether there is a in progress video recording.
|
Boolean |
isTapToFocusEnabled()
Returns whether tap-to-focus is enabled.
By default tap-to-focus is enabled.
|
Boolean |
isVideoCaptureEnabled()
Checks if video capture is enabled.
Video capture is disabled by default. It has to be enabled before startRecording can be called.
|
Unit |
setCameraSelector(@NonNull cameraSelector: CameraSelector)
Sets the CameraSelector .
Calling this method with a CameraSelector that resolves to a different camera will change the camera being used by the controller.
The default value is CameraSelector#DEFAULT_BACK_CAMERA .
|
Unit |
setEnabledUseCases(enabledUseCases: Int)
Enables or disables use cases.
Use cases need to be enabled before they can be used. By default, IMAGE_CAPTURE and IMAGE_ANALYSIS are enabled, and VIDEO_CAPTURE is disabled. This is necessary because VIDEO_CAPTURE is an experimental feature that might not work with other use cases, especially on lower end devices. When that happens, this method will fail with an IllegalStateException .
To make sure VIDEO_CAPTURE works, IMAGE_CAPTURE and IMAGE_ANALYSIS needs to be disabled when enabling VIDEO_CAPTURE . For example:
<code>
// By default, image capture is enabled. Taking picture works.
controller.takePicture(...);
// Switch to video capture to shoot video.
controller.setEnabledUseCases(VIDEO_CAPTURE);
controller.startRecording(...);
controller.stopRecording(...);
// Switch back to image capture and image analysis before taking another picture.
controller.setEnabledUseCases(IMAGE_CAPTURE|IMAGE_ANALYSIS);
controller.takePicture(...);
</code>
|
Unit |
setImageAnalysisAnalyzer(@NonNull executor: Executor, @NonNull analyzer: ImageAnalysis.Analyzer)
Sets an analyzer to receive and analyze images.
Applications can process or copy the image by implementing the ImageAnalysis.Analyzer . The image needs to be closed by calling ImageProxy#close() when the analyzing is done.
Setting an analyzer function replaces any previous analyzer. Only one analyzer can be set at any time.
|
Unit |
setImageAnalysisBackpressureStrategy(strategy: Int)
Sets the backpressure strategy to apply to the image producer to deal with scenarios where images may be produced faster than they can be analyzed.
The available values are ImageAnalysis#STRATEGY_BLOCK_PRODUCER and ImageAnalysis#STRATEGY_KEEP_ONLY_LATEST . If not set, the backpressure strategy will default to ImageAnalysis#STRATEGY_KEEP_ONLY_LATEST .
|
Unit |
setImageAnalysisImageQueueDepth(depth: Int)
Sets the image queue depth of ImageAnalysis .
This sets the number of images available in parallel to ImageAnalysis.Analyzer . The value is only used if the backpressure strategy is ImageAnalysis.BackpressureStrategy#STRATEGY_BLOCK_PRODUCER .
|
Unit |
setImageCaptureFlashMode(flashMode: Int)
Sets the flash mode for ImageCapture .
If not set, the flash mode will default to ImageCapture#FLASH_MODE_OFF .
|
ListenableFuture<Void!> |
setLinearZoom(linearZoom: Float)
Sets current zoom by a linear zoom value ranging from 0f to 1.0f. LinearZoom 0f represents the minimum zoom while linearZoom 1.0f represents the maximum zoom. The advantage of linearZoom is that it ensures the field of view (FOV) varies linearly with the linearZoom value, for use with slider UI elements (while setZoomRatio(float) works well for pinch-zoom gestures).
No-ops if the camera is not ready. The ListenableFuture completes successfully in this case.
|
Unit |
setPinchToZoomEnabled(enabled: Boolean)
Enables/disables pinch-to-zoom.
|