Message ID | 20210325135116.21548-4-jacopo@jmondi.org |
---|---|
State | Superseded |
Delegated to: | Jacopo Mondi |
Headers | show |
Series |
|
Related | show |
Hi Jacopo, Thanks for your work. On 2021-03-25 14:51:16 +0100, Jacopo Mondi wrote: > 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@jmondi.org> > --- > src/android/camera_device.cpp | 25 +++++++++++++------------ > 1 file changed, 13 insertions(+), 12 deletions(-) > > diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp > index 5fbf6f82ee9a..1d94e3a0b6ab 100644 > --- a/src/android/camera_device.cpp > +++ b/src/android/camera_device.cpp > @@ -931,15 +931,23 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() > staticMetadata_->addEntry(ANDROID_JPEG_MAX_SIZE, &maxJpegBufferSize_, 1); > > /* Sensor static metadata. */ > + int32_t pixelArraySize[2]; > { > const Size &size = > properties.get(properties::PixelArraySize); > - std::vector<int32_t> data{ > - static_cast<int32_t>(size.width), > - static_cast<int32_t>(size.height), > - }; > + pixelArraySize[0] = size.width; > + pixelArraySize[1] = size.height; > staticMetadata_->addEntry(ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE, > - data.data(), data.size()); > + pixelArraySize, 2); > + } > + > + if (properties.contains(properties::UnitCellSize)) { > + std::vector<float> physicalSize(2); I'm not sure what is 'nicer' int32_t pixelArraySize[2] or std::vector<float> physicalSize(2) (and the different addEntry() styles), but I think you should pick on or the other. Whit this aligned, Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> > + const Size &size = properties.get<Size>(properties::UnitCellSize); > + physicalSize[0] = size.width * pixelArraySize[0] / 1e6f; > + physicalSize[1] = size.height * pixelArraySize[1] / 1e6f; > + staticMetadata_->addEntry(ANDROID_SENSOR_INFO_PHYSICAL_SIZE, > + physicalSize.data(), physicalSize.size()); > } > > { > @@ -987,13 +995,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 > > _______________________________________________ > libcamera-devel mailing list > libcamera-devel@lists.libcamera.org > https://lists.libcamera.org/listinfo/libcamera-devel
diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 5fbf6f82ee9a..1d94e3a0b6ab 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -931,15 +931,23 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() staticMetadata_->addEntry(ANDROID_JPEG_MAX_SIZE, &maxJpegBufferSize_, 1); /* Sensor static metadata. */ + int32_t pixelArraySize[2]; { const Size &size = properties.get(properties::PixelArraySize); - std::vector<int32_t> data{ - static_cast<int32_t>(size.width), - static_cast<int32_t>(size.height), - }; + pixelArraySize[0] = size.width; + pixelArraySize[1] = size.height; staticMetadata_->addEntry(ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE, - data.data(), data.size()); + pixelArraySize, 2); + } + + if (properties.contains(properties::UnitCellSize)) { + std::vector<float> physicalSize(2); + const Size &size = properties.get<Size>(properties::UnitCellSize); + physicalSize[0] = size.width * pixelArraySize[0] / 1e6f; + physicalSize[1] = size.height * pixelArraySize[1] / 1e6f; + staticMetadata_->addEntry(ANDROID_SENSOR_INFO_PHYSICAL_SIZE, + physicalSize.data(), physicalSize.size()); } { @@ -987,13 +995,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);
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@jmondi.org> --- src/android/camera_device.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-)