From 45c6a7e6e8277fed743e4033d39deeb36a58a4b0 Mon Sep 17 00:00:00 2001 From: Jacopo Mondi Date: Fri, 18 Dec 2020 16:35:35 +0100 Subject: android: camera_device: Report sensor physical size MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Calculate the value of the ANDROID_SENSOR_INFO_PHYSICAL_SIZE property multiplying the number of sensor's readable pixels with the pixel unit cell size if provided by the Camera. Reviewed-by: Laurent Pinchart Reviewed-by: Hirokazu Honda Reviewed-by: Niklas Söderlund Signed-off-by: Jacopo Mondi --- src/android/camera_device.cpp | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index f1f26c77..7fc6868e 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -9,6 +9,7 @@ #include "camera_ops.h" #include "post_processor.h" +#include #include #include #include @@ -1032,15 +1033,23 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() staticMetadata_->addEntry(ANDROID_JPEG_MAX_SIZE, &maxJpegBufferSize_, 1); /* Sensor static metadata. */ + std::array pixelArraySize; { - const Size &size = - properties.get(properties::PixelArraySize); - std::vector data{ - static_cast(size.width), - static_cast(size.height), - }; + const Size &size = properties.get(properties::PixelArraySize); + pixelArraySize[0] = size.width; + pixelArraySize[1] = size.height; staticMetadata_->addEntry(ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE, - data.data(), data.size()); + pixelArraySize.data(), pixelArraySize.size()); + } + + if (properties.contains(properties::UnitCellSize)) { + const Size &cellSize = properties.get(properties::UnitCellSize); + std::array physicalSize{ + cellSize.width * pixelArraySize[0] / 1e6f, + cellSize.height * pixelArraySize[1] / 1e6f + }; + staticMetadata_->addEntry(ANDROID_SENSOR_INFO_PHYSICAL_SIZE, + physicalSize.data(), physicalSize.size()); } { @@ -1088,13 +1097,6 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() testPatterModes.data(), testPatterModes.size()); - std::vector physicalSize = { - 2592, 1944, - }; - staticMetadata_->addEntry(ANDROID_SENSOR_INFO_PHYSICAL_SIZE, - physicalSize.data(), - physicalSize.size()); - uint8_t timestampSource = ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE_UNKNOWN; staticMetadata_->addEntry(ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE, ×tampSource, 1); -- cgit v1.2.1