[libcamera-devel] [PATCH v4 3/3] android: camera_device: Report sensor physical size

Hirokazu Honda hiroh at chromium.org
Mon Apr 12 15:08:29 CEST 2021


Hi Jacopo, thanks for the patch.

On Mon, Apr 12, 2021 at 4:56 PM Jacopo Mondi <jacopo at jmondi.org> 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.
>
> Reviewed-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
> Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
> ---
>  src/android/camera_device.cpp | 30 ++++++++++++++++--------------
>  1 file changed, 16 insertions(+), 14 deletions(-)
>
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index 89044efa7ebe..754ee00af472 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 <array>
>  #include <cmath>
>  #include <fstream>
>  #include <sys/mman.h>
> @@ -1026,15 +1027,23 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()
>         staticMetadata_->addEntry(ANDROID_JPEG_MAX_SIZE, &maxJpegBufferSize_, 1);
>
>         /* Sensor static metadata. */
> +       std::array<int32_t, 2> pixelArraySize;
>         {
> -               const Size &size =
> -                       properties.get(properties::PixelArraySize);
> -               std::vector<int32_t> data{
> -                       static_cast<int32_t>(size.width),
> -                       static_cast<int32_t>(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<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());
>         }
>
>         {
> @@ -1082,13 +1091,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,
>                                   &timestampSource, 1);
> --
> 2.31.1
>

Reviewed-by: Hirokazu Honda <hiroh at chromium.org>

-Hiro

> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel at lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel


More information about the libcamera-devel mailing list