android: camera_device: Report sensor physical size

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 <laurent.pinchart@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
Jacopo Mondi 2020-12-18 16:35:35 +01:00
parent cdfcb05bed
commit 45c6a7e6e8

View file

@ -9,6 +9,7 @@
#include "camera_ops.h" #include "camera_ops.h"
#include "post_processor.h" #include "post_processor.h"
#include <array>
#include <cmath> #include <cmath>
#include <fstream> #include <fstream>
#include <sys/mman.h> #include <sys/mman.h>
@ -1032,15 +1033,23 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()
staticMetadata_->addEntry(ANDROID_JPEG_MAX_SIZE, &maxJpegBufferSize_, 1); staticMetadata_->addEntry(ANDROID_JPEG_MAX_SIZE, &maxJpegBufferSize_, 1);
/* Sensor static metadata. */ /* Sensor static metadata. */
std::array<int32_t, 2> pixelArraySize;
{ {
const Size &size = const Size &size = properties.get(properties::PixelArraySize);
properties.get(properties::PixelArraySize); pixelArraySize[0] = size.width;
std::vector<int32_t> data{ pixelArraySize[1] = size.height;
static_cast<int32_t>(size.width),
static_cast<int32_t>(size.height),
};
staticMetadata_->addEntry(ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE, 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<Size>(properties::UnitCellSize);
std::array<float, 2> 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.data(),
testPatterModes.size()); 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; uint8_t timestampSource = ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE_UNKNOWN;
staticMetadata_->addEntry(ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE, staticMetadata_->addEntry(ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE,
&timestampSource, 1); &timestampSource, 1);