/* * Copyright 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package androidx.camera.core; import android.graphics.ImageFormat; import android.view.Surface; import androidx.annotation.FloatRange; import androidx.annotation.NonNull; import androidx.annotation.RequiresApi; import androidx.annotation.RestrictTo; import androidx.annotation.RestrictTo.Scope; import androidx.annotation.StringDef; import androidx.camera.core.impl.ImageOutputConfig; import androidx.lifecycle.LifecycleOwner; import androidx.lifecycle.LiveData; import androidx.lifecycle.Observer; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; /** * An interface for retrieving camera information. * *
Applications can retrieve an instance via {@link Camera#getCameraInfo()}.
*/
@RequiresApi(21) // TODO(b/200306659): Remove and replace with annotation on package-info.java
public interface CameraInfo {
/**
* An unknown intrinsic zoom ratio. Usually to indicate the camera is unable to provide
* necessary information to resolve its intrinsic zoom ratio.
*
* @hide
*/
@RestrictTo(Scope.LIBRARY_GROUP)
float INTRINSIC_ZOOM_RATIO_UNKNOWN = 1.0F;
/**
* An unknown camera implementation type.
*
* @hide
*/
@RestrictTo(Scope.LIBRARY_GROUP)
@NonNull
String IMPLEMENTATION_TYPE_UNKNOWN = " See Sensor Coordinate System
* for more information.
*
* @return the sensor rotation in degrees, relative to device's "natural" (default) orientation.
*/
int getSensorRotationDegrees();
/**
* Returns the sensor rotation, in degrees, relative to the given rotation value.
*
* Valid values for the relative rotation are {@link Surface#ROTATION_0} (natural), {@link
* Surface#ROTATION_90}, {@link Surface#ROTATION_180}, {@link Surface#ROTATION_270}.
*
* @param relativeRotation the rotation relative to which the output will be calculated.
* @return the sensor rotation in degrees.
*/
int getSensorRotationDegrees(@ImageOutputConfig.RotationValue int relativeRotation);
/** Returns if flash unit is available or not. */
boolean hasFlashUnit();
/**
* Returns a {@link LiveData} of current {@link TorchState}.
*
* The torch can be turned on and off via {@link CameraControl#enableTorch(boolean)} which
* will trigger the change event to the returned {@link LiveData}. Apps can either get
* immediate value via {@link LiveData#getValue()} or observe it via
* {@link LiveData#observe(LifecycleOwner, Observer)} to update torch UI accordingly.
*
* If the camera doesn't have a flash unit (see {@link #hasFlashUnit()}), then the torch
* state will be {@link TorchState#OFF}.
*
* @return a {@link LiveData} containing current torch state.
*/
@NonNull
LiveData The LiveData will be updated whenever the set zoom state has been changed. This can
* occur when the application updates the zoom via {@link CameraControl#setZoomRatio(float)}
* or {@link CameraControl#setLinearZoom(float)}. The zoom state can also change anytime a
* camera starts up, for example when a {@link UseCase} is bound to it.
*/
@NonNull
LiveData The {@link ExposureState} contains the current exposure related information.
*/
@NonNull
ExposureState getExposureState();
/**
* Returns a {@link LiveData} of the camera's state.
*
* The {@link LiveData} will be updated whenever the {@linkplain CameraState camera's
* state} changes, and can be any of the following: {@link CameraState.Type#PENDING_OPEN},
* {@link CameraState.Type#OPENING}, {@link CameraState.Type#OPEN},
* {@link CameraState.Type#CLOSING} and {@link CameraState.Type#CLOSED}.
*
* Due to the inner workings of {@link LiveData}, some reported camera states may be
* ignored if a newer value is posted before the observers are updated. For instance, this can
* occur when the camera is opening or closing, the {@link CameraState.Type#OPENING} and
* {@link CameraState.Type#CLOSING} states may not be reported to observers if they are rapidly
* followed by the {@link CameraState.Type#OPEN} and {@link CameraState.Type#CLOSED} states
* respectively.
*
* @return a {@link LiveData} of the camera's state.
*/
@NonNull
LiveData The intrinsic zoom ratio is defined as the ratio between the angle of view of
* the default camera and this camera. The default camera is the camera selected by
* {@link CameraSelector#DEFAULT_FRONT_CAMERA} or {@link CameraSelector#DEFAULT_BACK_CAMERA}
* depending on the lens facing of this camera. For example, if the default camera has angle of
* view 60 degrees and this camera has 30 degrees, this camera will have intrinsic zoom ratio
* {@code 2.0}.
*
* The intrinsic zoom ratio is calculated approximately based on the focal length and the
* sensor size. It's considered an inexact attribute of the camera and might not be hundred
* percent accurate when compared with the output image. Especially for the case that the
* camera doesn't read the whole sensor area due to cropping being applied.
*
* The default camera is guaranteed to have intrinsic zoom ratio {@code 1.0}. Other cameras
* that have intrinsic zoom ratio greater than {@code 1.0} are considered telephoto cameras and
* cameras that have intrinsic zoom ratio less than {@code 1.0} are considered ultra
* wide-angle cameras.
*
* If the camera is unable to provide necessary information to resolve its intrinsic zoom
* ratio, it will be considered as a standard camera which has intrinsic zoom ratio {@code 1.0}.
*
* @return the intrinsic zoom ratio of this camera.
*/
@FloatRange(from = 0, fromInclusive = false)
default float getIntrinsicZoomRatio() {
return INTRINSIC_ZOOM_RATIO_UNKNOWN;
}
/**
* Returns if the given {@link FocusMeteringAction} is supported on the devices.
*
* It returns true if at least one valid AF/AE/AWB region generated by the given
* {@link FocusMeteringAction} is supported on the current camera. For example, on a camera
* supporting only AF regions, passing in a {@link FocusMeteringAction} specifying AF/AE regions
* to this API will still return true. But it will return false if the
* {@link FocusMeteringAction} specifies only the AE region since none of the specified
* regions are supported.
*
* If it returns false, invoking
* {@link CameraControl#startFocusAndMetering(FocusMeteringAction)} with the given
* {@link FocusMeteringAction} will always fail.
*/
default boolean isFocusMeteringSupported(@NonNull FocusMeteringAction action) {
return false;
}
/**
* Returns if {@link ImageCapture#CAPTURE_MODE_ZERO_SHUTTER_LAG} is supported on the current
* device.
*
* ZERO_SHUTTER_LAG will be supported when all of the following conditions are met
*
*
*
* @return true if supported, otherwise false.
*/
@ExperimentalZeroShutterLag
default boolean isZslSupported() {
return false;
}
/**
* Returns if {@link ImageFormat#PRIVATE} reprocessing is supported on the device.
*
* @return true if supported, otherwise false.
* @see android.hardware.camera2.CameraMetadata
* #REQUEST_AVAILABLE_CAPABILITIES_PRIVATE_REPROCESSING
* @hide
*/
@RestrictTo(Scope.LIBRARY_GROUP)
default boolean isPrivateReprocessingSupported() {
return false;
}
/** @hide */
@StringDef(open = true, value = {IMPLEMENTATION_TYPE_UNKNOWN,
IMPLEMENTATION_TYPE_CAMERA2_LEGACY, IMPLEMENTATION_TYPE_CAMERA2,
IMPLEMENTATION_TYPE_FAKE})
@Retention(RetentionPolicy.SOURCE)
@RestrictTo(Scope.LIBRARY_GROUP)
@interface ImplementationType {
}
}