From 7d2a5c5e7350658d0da4eaf75f9380593083e969 Mon Sep 17 00:00:00 2001 From: Igor Murashkin Date: Fri, 17 Jan 2014 15:07:52 -0800 Subject: [PATCH] camera2: Update spec for android.colorCorrection.* in metadata Change-Id: I02ba758f3da9e7c9e304591c410ca5385ebf4b4b --- .../android/hardware/camera2/CameraMetadata.java | 30 +++++++++-- .../android/hardware/camera2/CaptureRequest.java | 58 ++++++++++++++++++---- .../android/hardware/camera2/CaptureResult.java | 14 +++--- 3 files changed, 81 insertions(+), 21 deletions(-) diff --git a/core/java/android/hardware/camera2/CameraMetadata.java b/core/java/android/hardware/camera2/CameraMetadata.java index 3b1412ee3dee..8756dd1b615d 100644 --- a/core/java/android/hardware/camera2/CameraMetadata.java +++ b/core/java/android/hardware/camera2/CameraMetadata.java @@ -250,24 +250,44 @@ public abstract class CameraMetadata { /** *

Use the {@link CaptureRequest#COLOR_CORRECTION_TRANSFORM android.colorCorrection.transform} matrix - * and {@link CaptureRequest#COLOR_CORRECTION_GAINS android.colorCorrection.gains} to do color conversion

+ * and {@link CaptureRequest#COLOR_CORRECTION_GAINS android.colorCorrection.gains} to do color conversion.

+ *

All advanced white balance adjustments (not specified + * by our white balance pipeline) must be disabled.

+ *

If AWB is enabled with {@link CaptureRequest#CONTROL_AWB_MODE android.control.awbMode} != OFF, then + * TRANSFORM_MATRIX is ignored. The camera device will override + * this value to either FAST or HIGH_QUALITY.

* * @see CaptureRequest#COLOR_CORRECTION_GAINS * @see CaptureRequest#COLOR_CORRECTION_TRANSFORM + * @see CaptureRequest#CONTROL_AWB_MODE * @see CaptureRequest#COLOR_CORRECTION_MODE */ public static final int COLOR_CORRECTION_MODE_TRANSFORM_MATRIX = 0; /** - *

Must not slow down frame rate relative to raw - * bayer output

+ *

Must not slow down capture rate relative to sensor raw + * output.

+ *

Advanced white balance adjustments above and beyond + * the specified white balance pipeline may be applied.

+ *

If AWB is enabled with {@link CaptureRequest#CONTROL_AWB_MODE android.control.awbMode} != OFF, then + * the camera device uses the last frame's AWB values + * (or defaults if AWB has never been run).

+ * + * @see CaptureRequest#CONTROL_AWB_MODE * @see CaptureRequest#COLOR_CORRECTION_MODE */ public static final int COLOR_CORRECTION_MODE_FAST = 1; /** - *

Frame rate may be reduced by high - * quality

+ *

Capture rate (relative to sensor raw output) + * may be reduced by high quality.

+ *

Advanced white balance adjustments above and beyond + * the specified white balance pipeline may be applied.

+ *

If AWB is enabled with {@link CaptureRequest#CONTROL_AWB_MODE android.control.awbMode} != OFF, then + * the camera device uses the last frame's AWB values + * (or defaults if AWB has never been run).

+ * + * @see CaptureRequest#CONTROL_AWB_MODE * @see CaptureRequest#COLOR_CORRECTION_MODE */ public static final int COLOR_CORRECTION_MODE_HIGH_QUALITY = 2; diff --git a/core/java/android/hardware/camera2/CaptureRequest.java b/core/java/android/hardware/camera2/CaptureRequest.java index 4a3a7509194d..cd35de4fe633 100644 --- a/core/java/android/hardware/camera2/CaptureRequest.java +++ b/core/java/android/hardware/camera2/CaptureRequest.java @@ -319,9 +319,49 @@ public final class CaptureRequest extends CameraMetadata implements Parcelable { /** - *

When {@link CaptureRequest#CONTROL_AWB_MODE android.control.awbMode} is not OFF, TRANSFORM_MATRIX - * should be ignored.

+ *

The mode control selects how the image data is converted from the + * sensor's native color into linear sRGB color.

+ *

When auto-white balance is enabled with {@link CaptureRequest#CONTROL_AWB_MODE android.control.awbMode}, this + * control is overridden by the AWB routine. When AWB is disabled, the + * application controls how the color mapping is performed.

+ *

We define the expected processing pipeline below. For consistency + * across devices, this is always the case with TRANSFORM_MATRIX.

+ *

When either FULL or HIGH_QUALITY is used, the camera device may + * do additional processing but {@link CaptureRequest#COLOR_CORRECTION_GAINS android.colorCorrection.gains} and + * {@link CaptureRequest#COLOR_CORRECTION_TRANSFORM android.colorCorrection.transform} will still be provided by the + * camera device (in the results) and be roughly correct.

+ *

Switching to TRANSFORM_MATRIX and using the data provided from + * FAST or HIGH_QUALITY will yield a picture with the same white point + * as what was produced by the camera device in the earlier frame.

+ *

The expected processing pipeline is as follows:

+ *

White balance processing pipeline

+ *

The white balance is encoded by two values, a 4-channel white-balance + * gain vector (applied in the Bayer domain), and a 3x3 color transform + * matrix (applied after demosaic).

+ *

The 4-channel white-balance gains are defined as:

+ *
{@link CaptureRequest#COLOR_CORRECTION_GAINS android.colorCorrection.gains} = [ R G_even G_odd B ]
+     * 
+ *

where G_even is the gain for green pixels on even rows of the + * output, and G_odd is the gain for green pixels on the odd rows. + * These may be identical for a given camera device implementation; if + * the camera device does not support a separate gain for even/odd green + * channels, it will use the G_even value, and write G_odd equal to + * G_even in the output result metadata.

+ *

The matrices for color transforms are defined as a 9-entry vector:

+ *
{@link CaptureRequest#COLOR_CORRECTION_TRANSFORM android.colorCorrection.transform} = [ I0 I1 I2 I3 I4 I5 I6 I7 I8 ]
+     * 
+ *

which define a transform from input sensor colors, P_in = [ r g b ], + * to output linear sRGB, P_out = [ r' g' b' ],

+ *

with colors as follows:

+ *
r' = I0r + I1g + I2b
+     * g' = I3r + I4g + I5b
+     * b' = I6r + I7g + I8b
+     * 
+ *

Both the input and output value ranges must match. Overflow/underflow + * values are clipped to fit within the range.

* + * @see CaptureRequest#COLOR_CORRECTION_GAINS + * @see CaptureRequest#COLOR_CORRECTION_TRANSFORM * @see CaptureRequest#CONTROL_AWB_MODE * @see #COLOR_CORRECTION_MODE_TRANSFORM_MATRIX * @see #COLOR_CORRECTION_MODE_FAST @@ -347,20 +387,20 @@ public final class CaptureRequest extends CameraMetadata implements Parcelable { new Key("android.colorCorrection.transform", Rational[].class); /** - *

Gains applying to Bayer color channels for + *

Gains applying to Bayer raw color channels for * white-balance

*

The 4-channel white-balance gains are defined in - * the order of [R G_even G_odd B], where G_even is the gain - * for green pixels on even rows of the output, and G_odd - * is the gain for greenpixels on the odd rows. if a HAL + * the order of [R G_even G_odd B], where G_even is the gain + * for green pixels on even rows of the output, and G_odd + * is the gain for green pixels on the odd rows. if a HAL * does not support a separate gain for even/odd green channels, - * it should use the G_even value,and write G_odd equal to - * G_even in the output result metadata.

+ * it should use the G_even value, and write G_odd equal to + * G_even in the output result metadata.

*

This array is either set by HAL when the request * {@link CaptureRequest#COLOR_CORRECTION_MODE android.colorCorrection.mode} is not TRANSFORM_MATRIX, or * directly by the application in the request when the * {@link CaptureRequest#COLOR_CORRECTION_MODE android.colorCorrection.mode} is TRANSFORM_MATRIX.

- *

The ouput should be the gains actually applied by the HAL to + *

The output should be the gains actually applied by the HAL to * the current frame.

* * @see CaptureRequest#COLOR_CORRECTION_MODE diff --git a/core/java/android/hardware/camera2/CaptureResult.java b/core/java/android/hardware/camera2/CaptureResult.java index 96183908ca7a..aa12d5e8c52c 100644 --- a/core/java/android/hardware/camera2/CaptureResult.java +++ b/core/java/android/hardware/camera2/CaptureResult.java @@ -140,20 +140,20 @@ public final class CaptureResult extends CameraMetadata { new Key("android.colorCorrection.transform", Rational[].class); /** - *

Gains applying to Bayer color channels for + *

Gains applying to Bayer raw color channels for * white-balance

*

The 4-channel white-balance gains are defined in - * the order of [R G_even G_odd B], where G_even is the gain - * for green pixels on even rows of the output, and G_odd - * is the gain for greenpixels on the odd rows. if a HAL + * the order of [R G_even G_odd B], where G_even is the gain + * for green pixels on even rows of the output, and G_odd + * is the gain for green pixels on the odd rows. if a HAL * does not support a separate gain for even/odd green channels, - * it should use the G_even value,and write G_odd equal to - * G_even in the output result metadata.

+ * it should use the G_even value, and write G_odd equal to + * G_even in the output result metadata.

*

This array is either set by HAL when the request * {@link CaptureRequest#COLOR_CORRECTION_MODE android.colorCorrection.mode} is not TRANSFORM_MATRIX, or * directly by the application in the request when the * {@link CaptureRequest#COLOR_CORRECTION_MODE android.colorCorrection.mode} is TRANSFORM_MATRIX.

- *

The ouput should be the gains actually applied by the HAL to + *

The output should be the gains actually applied by the HAL to * the current frame.

* * @see CaptureRequest#COLOR_CORRECTION_MODE -- 2.11.0