ImageCapture
class ImageCapture : UseCase
kotlin.Any | ||
↳ | androidx.camera.core.UseCase | |
↳ | androidx.camera.core.ImageCapture |
A use case for taking a picture.
This class is designed for basic picture taking. It provides takePicture() functions to take a picture to memory or save to a file, and provides image metadata. Pictures are taken in automatic mode after focus has converged. The flash mode can additionally be set by the application.
TakePicture returns immediately and a listener is called to provide the results after the capture completes. Multiple calls to takePicture will take pictures sequentially starting after the previous picture is captured.
Note that focus and exposure metering regions can be controlled via Preview
.
When capturing to memory, the captured image is made available through an ImageProxy
via an ImageCapture.OnImageCapturedCallback
.
Summary
Nested classes | |
---|---|
Builder for an |
|
Holder class for metadata that will be saved with captured images. |
|
abstract |
Callback for when an image capture has completed. |
abstract |
Listener containing callbacks for image file I/O events. |
Options for saving newly captured image. |
|
Info about the saved image file. |
Constants | |
---|---|
static Int |
Optimizes capture pipeline to prioritize image quality over latency. |
static Int |
Optimizes capture pipeline to prioritize latency over image quality. |
static Int |
An error indicating the request cannot be done due to camera is closed. |
static Int |
An error reported by camera framework indicating the capture request is failed. |
static Int |
An error occurred while attempting to read or write a file, such as when saving an image to a File. |
static Int |
An error indicating this ImageCapture is not bound to a valid camera. |
static Int |
An unknown error occurred. |
static Int | |
static Int |
No flash. |
static Int |
Always flash. |
Public methods | |
---|---|
Int |
Returns the set capture mode. |
Int |
Get the flash mode. |
Int |
Returns the desired rotation of the output image. |
Unit |
setCropAspectRatio(@NonNull aspectRatio: Rational) Sets target cropping aspect ratio for output image. |
Unit |
setFlashMode(flashMode: Int) Set the flash mode. |
Unit |
setTargetRotation(rotation: Int) Sets the desired rotation of the output image. |
Unit |
takePicture(@NonNull executor: Executor, @NonNull callback: ImageCapture.OnImageCapturedCallback) Captures a new still image for in memory access. |
Unit |
takePicture(@NonNull outputFileOptions: ImageCapture.OutputFileOptions, @NonNull executor: Executor, @NonNull imageSavedCallback: ImageCapture.OnImageSavedCallback) Captures a new still image and saves to a file along with application specified metadata. |
String |
toString() |
Constants
CAPTURE_MODE_MAXIMIZE_QUALITY
static val CAPTURE_MODE_MAXIMIZE_QUALITY: Int
Optimizes capture pipeline to prioritize image quality over latency. When the capture mode is set to MAX_QUALITY, images may take longer to capture.
Value: 0
CAPTURE_MODE_MINIMIZE_LATENCY
static val CAPTURE_MODE_MINIMIZE_LATENCY: Int
Optimizes capture pipeline to prioritize latency over image quality. When the capture mode is set to MIN_LATENCY, images may capture faster but the image quality may be reduced.
Value: 1
ERROR_CAMERA_CLOSED
static val ERROR_CAMERA_CLOSED: Int
An error indicating the request cannot be done due to camera is closed.
Value: 3
ERROR_CAPTURE_FAILED
static val ERROR_CAPTURE_FAILED: Int
An error reported by camera framework indicating the capture request is failed.
Value: 2
ERROR_FILE_IO
static val ERROR_FILE_IO: Int
An error occurred while attempting to read or write a file, such as when saving an image to a File.
Value: 1
ERROR_INVALID_CAMERA
static val ERROR_INVALID_CAMERA: Int
An error indicating this ImageCapture is not bound to a valid camera.
Value: 4
ERROR_UNKNOWN
static val ERROR_UNKNOWN: Int
An unknown error occurred.
See message parameter in onError callback or log for more details.
Value: 0
FLASH_MODE_OFF
static val FLASH_MODE_OFF: Int
No flash. The flash will never be used when taking a picture.
Value: 2