From 505e49b76ed4f3040182f66a1c3884ea1648a612 Mon Sep 17 00:00:00 2001 From: Paul Elder Date: Mon, 16 Sep 2024 01:24:20 +0200 Subject: 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 Reviewed-by: Kieran Bingham Reviewed-by: Stefan Klug Reviewed-by: Laurent Pinchart Signed-off-by: Laurent Pinchart --- src/py/libcamera/py_main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/py') diff --git a/src/py/libcamera/py_main.cpp b/src/py/libcamera/py_main.cpp index ab33f38a..983b76f6 100644 --- a/src/py/libcamera/py_main.cpp +++ b/src/py/libcamera/py_main.cpp @@ -404,7 +404,8 @@ PYBIND11_MODULE(_libcamera, m) .def("__repr__", [](const ControlId &self) { return py::str("libcamera.ControlId({}, {}, {})") .format(self.id(), self.name(), self.type()); - }); + }) + .def("enumerators", &ControlId::enumerators); pyControlInfo .def_property_readonly("min", [](const ControlInfo &self) { -- cgit v1.2.1