[libcamera-devel] [PATCH v2 9/9] android: camera_device: Report sensor physical size

Jacopo Mondi jacopo at jmondi.org
Fri Dec 18 17:47:54 CET 2020


Report the ANDROID_SENSOR_INFO_PHYSICAL_SIZE property inspecting
the draft SensorPhysicalSize property reported by libcamera.

Maintain a default value to support pipelines that do not register
the camera property.

Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
---
 src/android/camera_device.cpp | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index bad8a51ae7f7..f50a539e907d 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -919,12 +919,20 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()
 				  testPatterModes.data(),
 				  testPatterModes.size());
 
-	std::vector<float> physicalSize = {
-		2592, 1944,
-	};
+	std::vector<float> physicalSize(2);
+	if (properties.contains(properties::draft::SensorPhysicalSize)) {
+		const Span<const float> data =
+			properties.get<Span<const float>>(properties::draft::SensorPhysicalSize);
+		physicalSize = { data[0], data[1] };
+	} else {
+		/*
+		 * \todo Drop the default once all pipelines report the
+		 * property.
+		 */
+		physicalSize = { 2.592, 1.944 };
+	}
 	staticMetadata_->addEntry(ANDROID_SENSOR_INFO_PHYSICAL_SIZE,
-				  physicalSize.data(),
-				  physicalSize.size());
+				  physicalSize.data(), physicalSize.size());
 
 	uint8_t timestampSource = ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE_UNKNOWN;
 	staticMetadata_->addEntry(ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE,
-- 
2.29.2



More information about the libcamera-devel mailing list