Android.Hardware.Camera2 Namespace

The android.hardware.camera2 package provides an interface to individual camera devices connected to an Android device.

Remarks

The android.hardware.camera2 package provides an interface to individual camera devices connected to an Android device. It replaces the deprecated Android.Hardware.Camera class.

This package models a camera device as a pipeline, which takes in input requests for capturing a single frame, captures the single image per the request, and then outputs one capture result metadata packet, plus a set of output image buffers for the request. The requests are processed in-order, and multiple requests can be in flight at once. Since the camera device is a pipeline with multiple stages, having multiple requests in flight is required to maintain full framerate on most Android devices.

To enumerate, query, and open available camera devices, obtain a Android.Hardware.Camera2.CameraManager instance.

Individual Android.Hardware.Camera2.CameraDevice provide a set of static property information that describes the hardware device and the available settings and output parameters for the device. This information is provided through the Android.Hardware.Camera2.CameraCharacteristics object, and is available through Android.Hardware.Camera2.CameraManager.GetCameraCharacteristics(string)

To capture or stream images from a camera device, the application must first create a Android.Hardware.Camera2.CameraCaptureSession with a set of output Surfaces for use with the camera device, with Android.Hardware.Camera2.CameraDevice.createCaptureSession(java.util.List<android.view.Surface>, android.hardware.camera2.CameraCaptureSession.StateCallback, android.os.Handler). Each Surface has to be pre-configured with an Android.Hardware.Camera2.Params.StreamConfigurationMap (if applicable) to match the sizes and formats available from the camera device. A target Surface can be obtained from a variety of classes, including Android.Views.SurfaceView, Android.Graphics.SurfaceTexture via Android.Views.Surface(Android.Graphics.SurfaceTexture), Android.Media.MediaCodec, Android.Media.MediaRecorder, Android.Renderscripts.Allocation, and Android.Media.ImageReader.

Generally, camera preview images are sent to Android.Views.SurfaceView or Android.Views.TextureView (via its Android.Graphics.SurfaceTexture). Capture of JPEG images or RAW buffers for Android.Hardware.Camera2.DngCreator can be done with Android.Media.ImageReader with the Android.Graphics.ImageFormat.Jpeg and Android.Graphics.ImageFormat.RawSensor formats. Application-driven processing of camera data in RenderScript, OpenGL ES, or directly in managed or native code is best done through Android.Renderscripts.Allocation with a YUV Android.Renderscripts.Type, Android.Graphics.SurfaceTexture, and Android.Media.ImageReader with a Android.Graphics.ImageFormat.Yuv420888 format, respectively.

The application then needs to construct a Android.Hardware.Camera2.CaptureRequest, which defines all the capture parameters needed by a camera device to capture a single image. The request also lists which of the configured output Surfaces should be used as targets for this capture. The CameraDevice has a Android.Hardware.Camera2.CameraDevice.CreateCaptureRequest(Android.Hardware.Camera2.CameraTemplate) for creating a NoType:android/hardware/camera2/CaptureRequest$Builder;Href=../../../../reference/android/hardware/camera2/CaptureRequest.Builder.html for a given use case, which is optimized for the Android device the application is running on.

Once the request has been set up, it can be handed to the active capture session either for a one-shot Android.Hardware.Camera2.CameraCaptureSession.Capture(Android.Hardware.Camera2.CaptureRequest, .CaptureCallback, .CaptureCallback) or for an endlessly Android.Hardware.Camera2.CameraCaptureSession.SetRepeatingRequest(Android.Hardware.Camera2.CaptureRequest, .CaptureCallback, .CaptureCallback) use. Both methods also have a variant that accepts a list of requests to use as a burst capture / repeating burst. Repeating requests have a lower priority than captures, so a request submitted through capture() while there's a repeating request configured will be captured before any new instances of the currently repeating (burst) capture will begin capture.

After processing a request, the camera device will produce a Android.Hardware.Camera2.TotalCaptureResult object, which contains information about the state of the camera device at time of capture, and the final settings used. These may vary somewhat from the request, if rounding or resolving contradictory parameters was necessary. The camera device will also send a frame of image data into each of the output Surfaces included in the request. These are produced asynchronously relative to the output CaptureResult, sometimes substantially later.

Classes

TypeReason
CameraAccessErrorTypeEnumerates values returned by several types and taken as a parameter of several methods of Android.Hardware.Camera2.CameraAccessException.
CameraAccessException
CameraCaptureSessionA configured capture session for a Android.Hardware.Camera2.CameraDevice, used for capturing images from the camera.
CameraCaptureSession+CaptureCallbackDocumentation for this section has not yet been entered.
CameraCaptureSession+StateCallbackDocumentation for this section has not yet been entered.
CameraCharacteristics
CameraCharacteristics+KeyDocumentation for this section has not yet been entered.
CameraDevice
CameraDevice+StateCallbackDocumentation for this section has not yet been entered.
CameraErrorEnumerates values returned by several methods of Android.Hardware.Camera2.CameraError and taken as a parameter of the Android.Hardware.Camera2.CameraDevice.StateCallback.OnError member.
CameraManager
CameraManager+AvailabilityCallbackDocumentation for this section has not yet been entered.
CameraMetadataThe base class for camera controls and information.
CameraTemplateEnumerates values returned by several methods of Android.Hardware.Camera2.CameraTemplate and taken as a parameter of the Android.Hardware.Camera2.CameraDevice.CreateCaptureRequest member.
CaptureFailureA report of failed capture for a single image capture from the image sensor.
CaptureFailureReasonEnumerates values returned by the Android.Hardware.Camera2.CaptureFailure.Reason, Android.Hardware.Camera2.CaptureFailureReason.Error, and Android.Hardware.Camera2.CaptureFailureReason.Flushed members.
CaptureRequest
CaptureRequest+BuilderDocumentation for this section has not yet been entered.
CaptureRequest+InterfaceConstsDocumentation for this section has not yet been entered.
CaptureRequest+KeyDocumentation for this section has not yet been entered.
CaptureResult
CaptureResult+KeyDocumentation for this section has not yet been entered.
ColorCorrectionAberrationModeEnumerates values returned by the Android.Hardware.Camera2.ColorCorrectionAberrationMode.Fast, Android.Hardware.Camera2.ColorCorrectionAberrationMode.HighQuality, and Android.Hardware.Camera2.ColorCorrectionAberrationMode.Off members.
ColorCorrectionModeEnumerates values returned by the Android.Hardware.Camera2.ColorCorrectionMode.Fast, Android.Hardware.Camera2.ColorCorrectionMode.HighQuality, and Android.Hardware.Camera2.ColorCorrectionMode.TransformMatrix members.
ControlAEAntibandingEnumerates values returned by several methods of Android.Hardware.Camera2.ControlAEAntibanding.
ControlAEModeEnumerates values returned by several methods of Android.Hardware.Camera2.ControlAEMode.
ControlAEPrecaptureTriggerEnumerates values returned by the Android.Hardware.Camera2.ControlAEPrecaptureTrigger.Idle, and Android.Hardware.Camera2.ControlAEPrecaptureTrigger.Start members.
ControlAEStateEnumerates values returned by several methods of Android.Hardware.Camera2.ControlAEState.
ControlAFModeEnumerates values returned by several methods of Android.Hardware.Camera2.ControlAFMode.
ControlAFStateEnumerates values returned by several methods of Android.Hardware.Camera2.ControlAFState.
ControlAFTriggerEnumerates values returned by the Android.Hardware.Camera2.ControlAFTrigger.Cancel, Android.Hardware.Camera2.ControlAFTrigger.Idle, and Android.Hardware.Camera2.ControlAFTrigger.Start members.
ControlAwbModeEnumerates values returned by several methods of Android.Hardware.Camera2.ControlAwbMode.
ControlAwbStateEnumerates values returned by several methods of Android.Hardware.Camera2.ControlAwbState.
ControlCaptureIntentEnumerates values returned by several methods of Android.Hardware.Camera2.ControlCaptureIntent.
ControlEffectModeEnumerates values returned by several methods of Android.Hardware.Camera2.ControlEffectMode.
ControlModeEnumerates values returned by several methods of Android.Hardware.Camera2.ControlMode.
ControlSceneModeEnumerates values returned by several methods of Android.Hardware.Camera2.ControlSceneMode.
ControlVideoStabilizationModeEnumerates values returned by the Android.Hardware.Camera2.ControlVideoStabilizationMode.Off, and Android.Hardware.Camera2.ControlVideoStabilizationMode.On members.
DngCreatorThe Android.Hardware.Camera2.DngCreator class provides functions to write raw pixel data as a DNG file.
EdgeModeEnumerates values returned by the Android.Hardware.Camera2.EdgeMode.Fast, Android.Hardware.Camera2.EdgeMode.HighQuality, and Android.Hardware.Camera2.EdgeMode.Off members.
FlashModeEnumerates values returned by the Android.Hardware.Camera2.FlashMode.Off, Android.Hardware.Camera2.FlashMode.Single, and Android.Hardware.Camera2.FlashMode.Torch members.
FlashStateEnumerates values returned by several methods of Android.Hardware.Camera2.FlashState.
HotPixelModeEnumerates values returned by the Android.Hardware.Camera2.HotPixelMode.Fast, Android.Hardware.Camera2.HotPixelMode.HighQuality, and Android.Hardware.Camera2.HotPixelMode.Off members.
InfoSupportedHardwareLevelEnumerates values returned by the Android.Hardware.Camera2.InfoSupportedHardwareLevel.Full, Android.Hardware.Camera2.InfoSupportedHardwareLevel.Legacy, and Android.Hardware.Camera2.InfoSupportedHardwareLevel.Limited members.
LensFacingEnumerates values returned by the Android.Hardware.Camera2.LensFacing.Back, and Android.Hardware.Camera2.LensFacing.Front members.
LensInfoFocusDistanceCalibrationEnumerates values returned by the Android.Hardware.Camera2.LensInfoFocusDistanceCalibration.Approximate, Android.Hardware.Camera2.LensInfoFocusDistanceCalibration.Calibrated, and Android.Hardware.Camera2.LensInfoFocusDistanceCalibration.Uncalibrated members.
LensOpticalStabilizationModeEnumerates values returned by the Android.Hardware.Camera2.LensOpticalStabilizationMode.Off, and Android.Hardware.Camera2.LensOpticalStabilizationMode.On members.
LensStateEnumerates values returned by the Android.Hardware.Camera2.LensState.Moving, and Android.Hardware.Camera2.LensState.Stationary members.
NoiseReductionModeEnumerates values returned by the Android.Hardware.Camera2.NoiseReductionMode.Fast, Android.Hardware.Camera2.NoiseReductionMode.HighQuality, and Android.Hardware.Camera2.NoiseReductionMode.Off members.
RequestAvailableCapabilitiesEnumerates values returned by several methods of Android.Hardware.Camera2.RequestAvailableCapabilities.
ScalerCroppingTypeEnumerates values returned by the Android.Hardware.Camera2.ScalerCroppingType.CenterOnly, and Android.Hardware.Camera2.ScalerCroppingType.Freeform members.
SensorInfoColorFilterArrangementEnumerates values returned by several methods of Android.Hardware.Camera2.SensorInfoColorFilterArrangement.
SensorInfoTimestampSourceEnumerates values returned by the Android.Hardware.Camera2.SensorInfoTimestampSource.Realtime, and Android.Hardware.Camera2.SensorInfoTimestampSource.Unknown members.
SensorReferenceIlluminant1Enumerates values returned by several methods of Android.Hardware.Camera2.SensorReferenceIlluminant1.
SensorTestPatternModeEnumerates values returned by several methods of Android.Hardware.Camera2.SensorTestPatternMode.
ShadingModeEnumerates values returned by the Android.Hardware.Camera2.ShadingMode.Fast, Android.Hardware.Camera2.ShadingMode.HighQuality, and Android.Hardware.Camera2.ShadingMode.Off members.
StatisticsFaceDetectModeEnumerates values returned by the Android.Hardware.Camera2.StatisticsFaceDetectMode.Full, Android.Hardware.Camera2.StatisticsFaceDetectMode.Off, and Android.Hardware.Camera2.StatisticsFaceDetectMode.Simple members.
StatisticsLensShadingMapModeEnumerates values returned by the Android.Hardware.Camera2.StatisticsLensShadingMapMode.Off, and Android.Hardware.Camera2.StatisticsLensShadingMapMode.On members.
StatisticsSceneFlickerEnumerates values returned by the Android.Hardware.Camera2.StatisticsSceneFlicker.None, Android.Hardware.Camera2.StatisticsSceneFlicker.S50hz, and Android.Hardware.Camera2.StatisticsSceneFlicker.S60hz members.
SyncMaxLatencyEnumerates values returned by the Android.Hardware.Camera2.SyncMaxLatency.PerFrameControl, and Android.Hardware.Camera2.SyncMaxLatency.Unknown members.
TonemapModeEnumerates values returned by the Android.Hardware.Camera2.TonemapMode.ContrastCurve, Android.Hardware.Camera2.TonemapMode.Fast, and Android.Hardware.Camera2.TonemapMode.HighQuality members.
TotalCaptureResult