diff options
author | Paul Elder <paul.elder@ideasonboard.com> | 2024-10-10 17:52:59 +0900 |
---|---|---|
committer | Paul Elder <paul.elder@ideasonboard.com> | 2024-11-25 22:28:26 +0900 |
commit | ea7f6faefe935ba09eb73963caff225f72adbbfc (patch) | |
tree | 4008ef59c40ab28154d17efbca5afe3a5d734717 /src/py | |
parent | 357dbc9f0e6d0e26f27553c2955cf580bc030394 (diff) |
py: Add bindings for ControlId array information
Add python bindings for querying whether or not a ControlId is an array
type, and the size.
Example usage:
>>> cid
libcamera.ControlId(28, FrameDurationLimits[2], ControlType.Integer64)
>>> cid.isArray
True
>>> cid.size
2
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/py')
-rw-r--r-- | src/py/libcamera/py_main.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/py/libcamera/py_main.cpp b/src/py/libcamera/py_main.cpp index 09b6f9db..441a70ab 100644 --- a/src/py/libcamera/py_main.cpp +++ b/src/py/libcamera/py_main.cpp @@ -7,6 +7,7 @@ #include "py_main.h" +#include <limits> #include <memory> #include <stdexcept> #include <string> @@ -401,10 +402,22 @@ PYBIND11_MODULE(_libcamera, m) .def_property_readonly("name", &ControlId::name) .def_property_readonly("vendor", &ControlId::vendor) .def_property_readonly("type", &ControlId::type) + .def_property_readonly("isArray", &ControlId::isArray) + .def_property_readonly("size", &ControlId::size) .def("__str__", [](const ControlId &self) { return self.name(); }) .def("__repr__", [](const ControlId &self) { - return py::str("libcamera.ControlId({}, {}.{}, {})") - .format(self.id(), self.vendor(), self.name(), self.type()); + std::string sizeStr = ""; + if (self.isArray()) { + sizeStr = "["; + size_t size = self.size(); + if (size == std::numeric_limits<size_t>::max()) + sizeStr += "n"; + else + sizeStr += std::to_string(size); + sizeStr += "]"; + } + return py::str("libcamera.ControlId({}, {}.{}{}, {})") + .format(self.id(), self.vendor(), self.name(), sizeStr, self.type()); }) .def("enumerators", &ControlId::enumerators); |