From 66c73ba846df91a2d0cc25650b17d50f80d0e785 Mon Sep 17 00:00:00 2001 From: Eino-Ville Talvala Date: Fri, 29 May 2015 16:11:56 -0700 Subject: [PATCH] Camera2: Add tangential distortion coefficients Also improve the documentation for the radialDistortion tag in general. Bug: 20123879 Change-Id: I8a725dedb9432a29bb731d603ca5c9fa89b8f9a4 --- .../camera2/CameraCharacteristics.java | 39 +++++++++++++------ .../hardware/camera2/CaptureResult.java | 39 +++++++++++++------ 2 files changed, 54 insertions(+), 24 deletions(-) diff --git a/core/java/android/hardware/camera2/CameraCharacteristics.java b/core/java/android/hardware/camera2/CameraCharacteristics.java index 4fe257c9e6f5b..d5867a9654f1b 100644 --- a/core/java/android/hardware/camera2/CameraCharacteristics.java +++ b/core/java/android/hardware/camera2/CameraCharacteristics.java @@ -1068,20 +1068,35 @@ public final class CameraCharacteristics extends CameraMetadataThe correction coefficients to correct for this camera device's - * radial lens distortion.

- *

Three cofficients [kappa_1, kappa_2, kappa_3] that - * can be used to correct the lens's radial geometric - * distortion with the mapping equations:

- *
 x_c = x_i * ( 1 + kappa_1 * r^2 + kappa_2 * r^4 + kappa_3 * r^6 )
-     * y_c = y_i * ( 1 + kappa_1 * r^2 + kappa_2 * r^4 + kappa_3 * r^6 )
+     * radial and tangential lens distortion.

+ *

Three radial distortion coefficients [kappa_1, kappa_2, + * kappa_3] and two tangential distortion coefficients + * [kappa_4, kappa_5] that can be used to correct the + * lens's geometric distortion with the mapping equations:

+ *
 x_c = x_i * ( 1 + kappa_1 * r^2 + kappa_2 * r^4 + kappa_3 * r^6 ) +
+     *        kappa_4 * (2 * x_i * y_i) + kappa_5 * ( r^2 + 2 * x_i^2 )
+     *  y_c = y_i * ( 1 + kappa_1 * r^2 + kappa_2 * r^4 + kappa_3 * r^6 ) +
+     *        kappa_5 * (2 * x_i * y_i) + kappa_4 * ( r^2 + 2 * y_i^2 )
      * 
- *

where [x_i, y_i] are normalized coordinates with (0,0) - * at the lens optical center, and [-1, 1] are the edges of - * the active pixel array; and where [x_c, y_c] are the - * corrected normalized coordinates with radial distortion - * removed; and r^2 = x_i^2 + y_i^2.

+ *

Here, [x_c, y_c] are the coordinates to sample in the + * input image that correspond to the pixel values in the + * corrected image at the coordinate [x_i, y_i]:

+ *
 correctedImage(x_i, y_i) = sample_at(x_c, y_c, inputImage)
+     * 
+ *

The pixel coordinates are defined in a normalized + * coordinate system related to the + * android.lens.intrinsicCalibration calibration fields. + * Both [x_i, y_i] and [x_c, y_c] have (0,0) at the + * lens optical center [c_x, c_y]. The maximum magnitudes + * of both x and y coordinates are normalized to be 1 at the + * edge further from the optical center, so the range + * for both dimensions is -1 <= x <= 1.

+ *

Finally, r represents the radial distance from the + * optical center, r^2 = x_i^2 + y_i^2, and its magnitude + * is therefore no larger than |r| <= sqrt(2).

+ *

The distortion model used is the Brown-Conrady model.

*

Units: - * Coefficients for a 6th-degree even radial polynomial.

+ * Unitless coefficients.

*

Optional - This value may be {@code null} on some devices.

*/ @PublicKey diff --git a/core/java/android/hardware/camera2/CaptureResult.java b/core/java/android/hardware/camera2/CaptureResult.java index f4017d0184b3f..93525ec0a7982 100644 --- a/core/java/android/hardware/camera2/CaptureResult.java +++ b/core/java/android/hardware/camera2/CaptureResult.java @@ -2649,20 +2649,35 @@ public class CaptureResult extends CameraMetadata> { /** *

The correction coefficients to correct for this camera device's - * radial lens distortion.

- *

Three cofficients [kappa_1, kappa_2, kappa_3] that - * can be used to correct the lens's radial geometric - * distortion with the mapping equations:

- *
 x_c = x_i * ( 1 + kappa_1 * r^2 + kappa_2 * r^4 + kappa_3 * r^6 )
-     * y_c = y_i * ( 1 + kappa_1 * r^2 + kappa_2 * r^4 + kappa_3 * r^6 )
+     * radial and tangential lens distortion.

+ *

Three radial distortion coefficients [kappa_1, kappa_2, + * kappa_3] and two tangential distortion coefficients + * [kappa_4, kappa_5] that can be used to correct the + * lens's geometric distortion with the mapping equations:

+ *
 x_c = x_i * ( 1 + kappa_1 * r^2 + kappa_2 * r^4 + kappa_3 * r^6 ) +
+     *        kappa_4 * (2 * x_i * y_i) + kappa_5 * ( r^2 + 2 * x_i^2 )
+     *  y_c = y_i * ( 1 + kappa_1 * r^2 + kappa_2 * r^4 + kappa_3 * r^6 ) +
+     *        kappa_5 * (2 * x_i * y_i) + kappa_4 * ( r^2 + 2 * y_i^2 )
      * 
- *

where [x_i, y_i] are normalized coordinates with (0,0) - * at the lens optical center, and [-1, 1] are the edges of - * the active pixel array; and where [x_c, y_c] are the - * corrected normalized coordinates with radial distortion - * removed; and r^2 = x_i^2 + y_i^2.

+ *

Here, [x_c, y_c] are the coordinates to sample in the + * input image that correspond to the pixel values in the + * corrected image at the coordinate [x_i, y_i]:

+ *
 correctedImage(x_i, y_i) = sample_at(x_c, y_c, inputImage)
+     * 
+ *

The pixel coordinates are defined in a normalized + * coordinate system related to the + * android.lens.intrinsicCalibration calibration fields. + * Both [x_i, y_i] and [x_c, y_c] have (0,0) at the + * lens optical center [c_x, c_y]. The maximum magnitudes + * of both x and y coordinates are normalized to be 1 at the + * edge further from the optical center, so the range + * for both dimensions is -1 <= x <= 1.

+ *

Finally, r represents the radial distance from the + * optical center, r^2 = x_i^2 + y_i^2, and its magnitude + * is therefore no larger than |r| <= sqrt(2).

+ *

The distortion model used is the Brown-Conrady model.

*

Units: - * Coefficients for a 6th-degree even radial polynomial.

+ * Unitless coefficients.

*

Optional - This value may be {@code null} on some devices.

*/ @PublicKey