[libcamera-devel] [PATCH v3 3/3] android: camera_device: Report sensor physical size
Jacopo Mondi
jacopo at jmondi.org
Thu Mar 25 14:43:25 CET 2021
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.
Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
---
src/android/camera_device.cpp | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index 5fbf6f82ee9a..ef5ed37e829a 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -940,6 +940,15 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()
};
staticMetadata_->addEntry(ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE,
data.data(), data.size());
+
+ std::vector<float> physicalSize(2);
+ if (properties.contains(properties::UnitCellSize)) {
+ const Size &unitCellSize =
+ properties.get<Size>(properties::UnitCellSize);
+ physicalSize[0] = unitCellSize.width * pixelArraySize[0] / 1e6f;
+ physicalSize[1] = unitCellSize.height * pixelArraySize[1] / 1e6f;
+ staticMetadata_->addEntry(ANDROID_SENSOR_INFO_PHYSICAL_SIZE,
+ physicalSize.data(), physicalSize.size());
}
{
@@ -987,13 +996,6 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()
testPatterModes.data(),
testPatterModes.size());
- std::vector<float> 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);
--
2.30.0
More information about the libcamera-devel
mailing list