[libcamera-devel] [PATCH] py: Add the SensorConfiguration class
David Plowman
david.plowman at raspberrypi.com
Wed Oct 11 11:37:49 CEST 2023
Hi Tomi
On Thu, 5 Oct 2023 at 11:03, Tomi Valkeinen
<tomi.valkeinen at ideasonboard.com> wrote:
>
> 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:
Yes, that's a fair point. I guess the only reason was that I don't use
those other fields, in large part because there's currently no way to
discover what values you'd put into them, so you'd struggle to do
anything meaningful with them!
But I could add simple accessors to these other bits of data where
that's straightforward. Do we think that would be useful?
Thanks!
David
>
> 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