Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c1021590 authored by Emilian Peev's avatar Emilian Peev
Browse files

Camera: Add the physical camera source crop metadata tag

Additionally map the source crop capture result
position according to the current distortion, rotate and crop
etc.
Enable intra-frame lens intrinsic samples as well.

Bug: 297083874
Test: Camera CTS
Change-Id: Ic07cb5b84dcc3e624b6443aeacb73c60799eff01
parent ae7c053c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ aconfig_declarations {
cc_aconfig_library {
    name: "camera_platform_flags_c_lib",
    aconfig_declarations: "camera_platform_flags",
    host_supported: true,
}

java_aconfig_library {
+82 −0
Original line number Diff line number Diff line
@@ -6494,6 +6494,40 @@ typedef enum acamera_metadata_tag {
     */
    ACAMERA_STATISTICS_OIS_Y_SHIFTS =                           // float[n]
            ACAMERA_STATISTICS_START + 20,
    /**
     * <p>An array of timestamps of lens intrinsics samples, in nanoseconds.</p>
     *
     * <p>Type: int64[n]</p>
     *
     * <p>This tag may appear in:
     * <ul>
     *   <li>ACameraMetadata from ACameraCaptureSession_captureCallback_result callbacks</li>
     * </ul></p>
     *
     * <p>The array contains the timestamps of lens intrinsics samples. The timestamps are in the
     * same timebase as and comparable to ACAMERA_SENSOR_TIMESTAMP.</p>
     *
     * @see ACAMERA_SENSOR_TIMESTAMP
     */
    ACAMERA_STATISTICS_LENS_INTRINSIC_TIMESTAMPS =              // int64[n]
            ACAMERA_STATISTICS_START + 21,
    /**
     * <p>An array of intra-frame lens intrinsics.</p>
     *
     * <p>Type: float[5*n]</p>
     *
     * <p>This tag may appear in:
     * <ul>
     *   <li>ACameraMetadata from ACameraCaptureSession_captureCallback_result callbacks</li>
     * </ul></p>
     *
     * <p>The data layout and contents of individual array entries matches with
     * ACAMERA_LENS_INTRINSIC_CALIBRATION.</p>
     *
     * @see ACAMERA_LENS_INTRINSIC_CALIBRATION
     */
    ACAMERA_STATISTICS_LENS_INTRINSIC_SAMPLES =                 // float[5*n]
            ACAMERA_STATISTICS_START + 22,
    ACAMERA_STATISTICS_END,
    /**
@@ -7468,6 +7502,54 @@ typedef enum acamera_metadata_tag {
     */
    ACAMERA_LOGICAL_MULTI_CAMERA_ACTIVE_PHYSICAL_ID =           // byte
            ACAMERA_LOGICAL_MULTI_CAMERA_START + 2,
    /**
     * <p>The current region of the active physical sensor that will be read out for this
     * capture.</p>
     *
     * <p>Type: int32[4]</p>
     *
     * <p>This tag may appear in:
     * <ul>
     *   <li>ACameraMetadata from ACameraCaptureSession_captureCallback_result callbacks</li>
     * </ul></p>
     *
     * <p>This capture result matches with ACAMERA_SCALER_CROP_REGION on non-logical single
     * camera sensor devices. In case of logical cameras that can switch between several
     * physical devices in response to ACAMERA_CONTROL_ZOOM_RATIO, this capture result will
     * not behave like ACAMERA_SCALER_CROP_REGION and ACAMERA_CONTROL_ZOOM_RATIO, where the
     * combination of both reflects the effective zoom and crop of the logical camera output.
     * Instead, this capture result value will describe the zoom and crop of the active physical
     * device. Some examples of when the value of this capture result will change include
     * switches between different physical lenses, switches between regular and maximum
     * resolution pixel mode and going through the device digital or optical range.
     * This capture result is similar to ACAMERA_SCALER_CROP_REGION with respect to distortion
     * correction. When the distortion correction mode is OFF, the coordinate system follows
     * ACAMERA_SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE, with (0, 0) being the top-left pixel
     * of the pre-correction active array. When the distortion correction mode is not OFF,
     * the coordinate system follows ACAMERA_SENSOR_INFO_ACTIVE_ARRAY_SIZE, with (0, 0) being
     * the top-left pixel of the active array.</p>
     * <p>For camera devices with the
     * <a href="https://developer.android.com/reference/android/hardware/camera2/CameraMetadata.html#REQUEST_AVAILABLE_CAPABILITIES_ULTRA_HIGH_RESOLUTION_SENSOR">CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_ULTRA_HIGH_RESOLUTION_SENSOR</a>
     * capability or devices where <a href="https://developer.android.com/reference/CameraCharacteristics.html#getAvailableCaptureRequestKeys">CameraCharacteristics#getAvailableCaptureRequestKeys</a>
     * lists <a href="https://developer.android.com/reference/CaptureRequest.html#SENSOR_PIXEL_MODE">ACAMERA_SENSOR_PIXEL_MODE</a>
     * , the current active physical device
     * ACAMERA_SENSOR_INFO_ACTIVE_ARRAY_SIZE_MAXIMUM_RESOLUTION /
     * ACAMERA_SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE_MAXIMUM_RESOLUTION must be used as the
     * coordinate system for requests where ACAMERA_SENSOR_PIXEL_MODE is set to
     * <a href="https://developer.android.com/reference/android/hardware/camera2/CameraMetadata.html#SENSOR_PIXEL_MODE_MAXIMUM_RESOLUTION">CameraMetadata#SENSOR_PIXEL_MODE_MAXIMUM_RESOLUTION</a>.</p>
     * <p>The data representation is int[4], which maps to (left, top, width, height).</p>
     *
     * @see ACAMERA_CONTROL_ZOOM_RATIO
     * @see ACAMERA_SCALER_CROP_REGION
     * @see ACAMERA_SENSOR_INFO_ACTIVE_ARRAY_SIZE
     * @see ACAMERA_SENSOR_INFO_ACTIVE_ARRAY_SIZE_MAXIMUM_RESOLUTION
     * @see ACAMERA_SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE
     * @see ACAMERA_SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE_MAXIMUM_RESOLUTION
     * @see ACAMERA_SENSOR_PIXEL_MODE
     */
    ACAMERA_LOGICAL_MULTI_CAMERA_ACTIVE_PHYSICAL_SENSOR_CROP_REGION = 
                                                                // int32[4]
            ACAMERA_LOGICAL_MULTI_CAMERA_START + 3,
    ACAMERA_LOGICAL_MULTI_CAMERA_END,
    /**
+1 −0
Original line number Diff line number Diff line
@@ -258,6 +258,7 @@ cc_library_static {
        "liblog",
        "libutils",
        "libxml2",
        "camera_platform_flags_c_lib"
    ],

    include_dirs: [
+3 −0
Original line number Diff line number Diff line
@@ -113,6 +113,9 @@ std::map<int, std::vector<camera_metadata_tag>> dynamic_api_level_to_keys{
          ANDROID_EXTENSION_CURRENT_TYPE,
          ANDROID_EXTENSION_STRENGTH,
          ANDROID_FLASH_STRENGTH_LEVEL,
          ANDROID_LOGICAL_MULTI_CAMERA_ACTIVE_PHYSICAL_SENSOR_CROP_REGION,
          ANDROID_SCALER_RAW_CROP_REGION,
          ANDROID_STATISTICS_LENS_INTRINSIC_SAMPLES,
          ANDROID_STATISTICS_LENS_INTRINSIC_TIMESTAMPS,
        }  },
};
+4 −0
Original line number Diff line number Diff line
@@ -17,13 +17,17 @@
#ifndef ANDROID_SERVERS_COORDINATEMAPPER_H
#define ANDROID_SERVERS_COORDINATEMAPPER_H

#include <algorithm>
#include <array>
#include <com_android_internal_camera_flags.h>
#include <set>

namespace android {

namespace camera3 {

namespace flags = com::android::internal::camera::flags;

class CoordinateMapper {
public:
    // The result metadata tags that are to be re-mapped
Loading