py: Add bindings for ControlId enum name

Add python bindings for querying enum value names from a ControlId.

Example usage:
>>> cid
libcamera.ControlId(16, AwbMode, ControlType.Integer32)
>>> cid.enumerators()
{0: 'AwbAuto', 1: 'AwbIncandescent', 2: 'AwbTungsten', 3: 'AwbFluorescent', 4: 'AwbIndoor', 5: 'AwbDaylight', 6: 'AwbCloudy', 7: 'AwbCustom'}
>>> cinfo
libcamera.ControlInfo([2..5])
>>> cinfo.values
[2, 3, 5]
>>> [cid.enumerators()[v] for v in cinfo.values]
['AwbTungsten', 'AwbFluorescent', 'AwbDaylight']

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Paul Elder 2024-09-16 01:24:20 +02:00 committed by Laurent Pinchart
parent ab48009a81
commit 505e49b76e

View file

@ -404,7 +404,8 @@ PYBIND11_MODULE(_libcamera, m)
.def("__repr__", [](const ControlId &self) { .def("__repr__", [](const ControlId &self) {
return py::str("libcamera.ControlId({}, {}, {})") return py::str("libcamera.ControlId({}, {}, {})")
.format(self.id(), self.name(), self.type()); .format(self.id(), self.name(), self.type());
}); })
.def("enumerators", &ControlId::enumerators);
pyControlInfo pyControlInfo
.def_property_readonly("min", [](const ControlInfo &self) { .def_property_readonly("min", [](const ControlInfo &self) {