**New features**
Changes to setting aspect ratios
setTargetAspectRatioMode() is added and accepts an enum argument. AspectRatioMode with options RATIO_4_3 or RATIO_16_9 instead of an arbitrary aspect ratio. This closer reflects the fact that only certain aspect ratios are provided from the camera, rather than any arbitrary ratio.
Currently 16:9 and 4:3 are available. In the case of 1:1, only certain devices have this available from the camera, and then only at limited resolutions. Applications designing a 1:1 interface or processing should use the more flexible 16:9 or 4:3 choices and crop at the display or process a subregion.
These aspect ratios are oriented to use the maximum sensor area
For each use case, applications should call only one of setTargetResolution() or setTargetAspectRatio(). Calling both on the same builder will return an error.
In general it’s recommended to use setTargetAspectRatio() based on the application’s UI design. Specific resolutions will be based on the use case (see table). For example preview will be near screen resolutions and image capture will provide high resolution stills. See table in the developer documentation.
setTargetResolution() can be used in more specific cases such as when minimum (to save computation) or maximum resolutions (for processing details) are required.
getTargetAspectRatio() added to use case config APIs returning aspect ratio the use case output is targeted for.
Previous setTargetAspectRatio(Rational aspectRatio) is now available for ImageCapture as setTargetAspectRatioCustom(Rational aspectRatio) and when set the ImageCapture output will be cropped accordingly.
Executor APIs
Removed the setCallbackHandler() call from use case configuration APIs. Instead, applications can set executors parameters added to various API functions.
The following functions accept an executor parameter that allows the app to control which executor the function runs on.
Preview.setOnPreviewOutputUpdateListener() API. If the executor is not present for that function, it executes on the main thread.
Preview.setOnPreviewOutputUpdateListener
FocusMeteringAction.Builder.setAutoFocusCallback
ImageAnalysis.setAnalyzer
ImageCapture.takePicture
CameraView.takePicture
CameraView.startRecording
VideoCapture.startRecording
CameraInfo added with check Flash Available and Sensor Rotation APIs
Added a CameraInfo and getCameraInfo method, which allow app to check if a lens facing CameraInfo is available, and if a flash is available on that camera, e.g.:
try {
CameraInfo cameraInfo = CameraX.getCameraInfo(mCurrentCameraLensFacing);
LiveData<Boolean> isFlashAvailable = cameraInfo.isFlashAvailable();
flashToggle.setVisibility(
isFlashAvailable.getValue() ? View.VISIBLE : View.INVISIBLE);
} catch (CameraInfoUnavailableException e) {
Log.w(TAG, "Cannot get flash available information", e);
flashToggle.setVisibility(View.VISIBLE);
}
CameraInfo.getSensorRotationDegrees() added providing the camera sensor orientation relative to the device’s natural orientation, or for convenience relative to an orientation described by a Surface rotation (which describes an orientation relative to natural orientation).
**API changes & Bug fixes**
Camera Extensions commits - 1.0.0-alpha03
Camera View commits - 1.0.0-alpha03
**New Features**
Added Context initializer for extensions, extensions version incremented to 1.1.0