[libcamera-devel] [PATCH] py: Add the SensorConfiguration class

Tomi Valkeinen tomi.valkeinen at ideasonboard.com
Thu Oct 5 12:03:46 CEST 2023


On 28/09/2023 12:45, David Plowman via libcamera-devel wrote:
> We provide access to the bitDepth and outputSize fields of the new
> SensorConfiguration class. The class also needs a constructor so that
> Python applications can make one and put it into the
> CameraConfiguration.
> 
> Signed-off-by: David Plowman <david.plowman at raspberrypi.com>
> ---
>   src/py/libcamera/py_main.cpp | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
> diff --git a/src/py/libcamera/py_main.cpp b/src/py/libcamera/py_main.cpp
> index 01fb15a9..8df04520 100644
> --- a/src/py/libcamera/py_main.cpp
> +++ b/src/py/libcamera/py_main.cpp
> @@ -112,6 +112,7 @@ PYBIND11_MODULE(_libcamera, m)
>   
>   	auto pyCameraManager = py::class_<PyCameraManager, std::shared_ptr<PyCameraManager>>(m, "CameraManager");
>   	auto pyCamera = py::class_<Camera, PyCameraSmartPtr<Camera>>(m, "Camera");
> +	auto pySensorConfiguration = py::class_<SensorConfiguration>(m, "SensorConfiguration");
>   	auto pyCameraConfiguration = py::class_<CameraConfiguration>(m, "CameraConfiguration");
>   	auto pyCameraConfigurationStatus = py::enum_<CameraConfiguration::Status>(pyCameraConfiguration, "Status");
>   	auto pyStreamConfiguration = py::class_<StreamConfiguration>(m, "StreamConfiguration");
> @@ -281,6 +282,11 @@ PYBIND11_MODULE(_libcamera, m)
>   			return ret;
>   		});
>   
> +	pySensorConfiguration
> +		.def(py::init<>())
> +		.def_readwrite("bit_depth", &SensorConfiguration::bitDepth)
> +		.def_readwrite("output_size", &SensorConfiguration::outputSize);
> +

Any reason not to expose all the fields in the class? In any case, looks 
fine to me:

Reviewed-by: Tomi Valkeinen <tomi.valkeinen at ideasonboard.com>


>   	pyCameraConfiguration
>   		.def("__iter__", [](CameraConfiguration &self) {
>   			return py::make_iterator<py::return_value_policy::reference_internal>(self);
> @@ -293,6 +299,7 @@ PYBIND11_MODULE(_libcamera, m)
>   		     py::return_value_policy::reference_internal)
>   		.def_property_readonly("size", &CameraConfiguration::size)
>   		.def_property_readonly("empty", &CameraConfiguration::empty)
> +		.def_readwrite("sensor_config", &CameraConfiguration::sensorConfig)
>   		.def_readwrite("transform", &CameraConfiguration::transform);
>   
>   	pyCameraConfigurationStatus



More information about the libcamera-devel mailing list