[libcamera-devel] [PATCH v6 1/3] libcamera: Introduce camera sensor properties
Niklas Söderlund
niklas.soderlund at ragnatech.se
Sat May 1 08:20:53 CEST 2021
Hi Jacopo,
Thanks for your work.
On 2021-04-30 19:38:01 +0200, Jacopo Mondi wrote:
> Introduce a database of camera sensor properties, which contains
> information on the camera sensor which are not possible, or desirable,
> to retrieve from the device at run time.
>
> The camera sensor database is accessed through a static function and
> is indexed using the camera sensor model as reported by
> properties::Model.
>
> Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
> ---
> .../internal/camera_sensor_properties.h | 24 +++++++
> include/libcamera/internal/meson.build | 1 +
> src/libcamera/camera_sensor_properties.cpp | 71 +++++++++++++++++++
> src/libcamera/meson.build | 1 +
> 4 files changed, 97 insertions(+)
> create mode 100644 include/libcamera/internal/camera_sensor_properties.h
> create mode 100644 src/libcamera/camera_sensor_properties.cpp
>
> diff --git a/include/libcamera/internal/camera_sensor_properties.h b/include/libcamera/internal/camera_sensor_properties.h
> new file mode 100644
> index 000000000000..f5e242cb34a2
> --- /dev/null
> +++ b/include/libcamera/internal/camera_sensor_properties.h
> @@ -0,0 +1,24 @@
> +/* SPDX-License-Identifier: LGPL-2.1-or-later */
> +/*
> + * Copyright (C) 2021, Google Inc.
> + *
> + * camera_sensor_properties.h - Database of camera sensor properties
> + */
> +#ifndef __LIBCAMERA_SENSOR_CAMERA_SENSOR_PROPERTIES_H__
> +#define __LIBCAMERA_SENSOR_CAMERA_SENSOR_PROPERTIES_H__
> +
> +#include <string>
> +
> +#include <libcamera/geometry.h>
> +
> +namespace libcamera {
> +
> +struct CameraSensorProperties {
> + static const CameraSensorProperties *get(const std::string &sensor);
> +
> + Size unitCellSize;
> +};
> +
> +} /* namespace libcamera */
> +
> +#endif /* __LIBCAMERA_SENSOR_CAMERA_SENSOR_PROPERTIES_H__ */
> diff --git a/include/libcamera/internal/meson.build b/include/libcamera/internal/meson.build
> index 1fe3918cfe93..6cff1b9032c6 100644
> --- a/include/libcamera/internal/meson.build
> +++ b/include/libcamera/internal/meson.build
> @@ -15,6 +15,7 @@ libcamera_internal_headers = files([
> 'byte_stream_buffer.h',
> 'camera_controls.h',
> 'camera_sensor.h',
> + 'camera_sensor_properties.h',
> 'control_serializer.h',
> 'control_validator.h',
> 'delayed_controls.h',
> diff --git a/src/libcamera/camera_sensor_properties.cpp b/src/libcamera/camera_sensor_properties.cpp
> new file mode 100644
> index 000000000000..6ded31dcae4f
> --- /dev/null
> +++ b/src/libcamera/camera_sensor_properties.cpp
> @@ -0,0 +1,71 @@
> +/* SPDX-License-Identifier: LGPL-2.1-or-later */
> +/*
> + * Copyright (C) 2021, Google Inc.
> + *
> + * camera_sensor_properties.cpp - Database of camera sensor properties
> + */
> +
> +#include "libcamera/internal/camera_sensor_properties.h"
> +
> +#include <map>
> +
> +#include "libcamera/internal/log.h"
> +
> +/**
> + * \file camera_sensor_properties.h
> + * \brief Database of camera sensor properties
> + *
> + * The database of camera sensor properties collects static information about
> + * camera sensors that is not possible or desirable to retrieve from the device
> + * at run time.
> + *
> + * The database is indexed using the camera sensor model, as reported by the
> + * properties::Model property, and for each supported sensor it contains a
> + * list of properties.
> + */
> +
> +namespace libcamera {
> +
> +LOG_DEFINE_CATEGORY(CameraSensorProperties)
> +
> +/**
> + * \struct CameraSensorProperties
> + * \brief Database of camera sensor properties
> + *
> + * \var CameraSensorProperties::unitCellSize
> + * \brief The physical size of a pixel, including pixel edges, in nanometers.
> + */
> +
> +/**
> + * \brief Retrieve the properties associated with a sensor
> + * \param sensor The sensor model name as reported by properties::Model
> + * \return A pointer to the CameraSensorProperties instance associated with a sensor
> + * or nullptr if the sensor is not supported
> + */
> +const CameraSensorProperties *CameraSensorProperties::get(const std::string &sensor)
> +{
> + static const std::map<std::string, const CameraSensorProperties> sensorProps = {
> + { "imx219", {
> + .unitCellSize = { 1120, 1120 },
> + } },
> + { "ov5670", {
> + .unitCellSize = { 1120, 1120 },
> + } },
> + { "ov13858", {
> + .unitCellSize = { 1120, 1120 },
> + } },
> + };
> +
> + const auto it = sensorProps.find(sensor);
> + if (it == sensorProps.end()) {
> + LOG(CameraSensorProperties, Warning)
> + << "No static properties available for '" << sensor << "'";
> + LOG(CameraSensorProperties, Warning)
> + << "Please consider updating the camera sensor properties database";
nit: I still cringe when I read log messages split in two statements :-)
Reviewed-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
> + return nullptr;
> + }
> +
> + return &it->second;
> +}
> +
> +} /* namespace libcamera */
> diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
> index e0a48aa23ea5..675053d41513 100644
> --- a/src/libcamera/meson.build
> +++ b/src/libcamera/meson.build
> @@ -9,6 +9,7 @@ libcamera_sources = files([
> 'camera_controls.cpp',
> 'camera_manager.cpp',
> 'camera_sensor.cpp',
> + 'camera_sensor_properties.cpp',
> 'class.cpp',
> 'controls.cpp',
> 'control_serializer.cpp',
> --
> 2.31.1
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel at lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
--
Regards,
Niklas Söderlund
More information about the libcamera-devel
mailing list