@@ -16,7 +16,7 @@ namespace py = pybind11;
using namespace libcamera;
template<typename T>
-static py::object valueOrTuple(const ControlValue &cv)
+static py::object valueOrTuple(const ControlValueView &cv)
{
if (cv.isArray()) {
const T *v = reinterpret_cast<const T *>(cv.data().data());
@@ -31,7 +31,7 @@ static py::object valueOrTuple(const ControlValue &cv)
return py::cast(cv.get<T>());
}
-py::object controlValueToPy(const ControlValue &cv)
+py::object controlValueToPy(const ControlValueView &cv)
{
switch (cv.type()) {
case ControlTypeNone:
@@ -9,5 +9,5 @@
#include <pybind11/pybind11.h>
-pybind11::object controlValueToPy(const libcamera::ControlValue &cv);
+pybind11::object controlValueToPy(const libcamera::ControlValueView &cv);
libcamera::ControlValue pyToControlValue(const pybind11::object &ob, libcamera::ControlType type);
@@ -460,14 +460,13 @@ PYBIND11_MODULE(_libcamera, m)
self.controls().set(id.id(), pyToControlValue(value, id.type()));
})
.def_property_readonly("metadata", [](Request &self) {
- /* Convert ControlList to std container */
+ /* Convert MetadataList to std container */
std::unordered_map<const ControlId *, py::object> ret;
- for (const auto &[key, cv] : self.metadata()) {
- const ControlId *id = controls::controls.at(key);
- py::object ob = controlValueToPy(cv);
- ret[id] = ob;
+ for (const auto &[k, v] : self.metadata2()) {
+ const ControlId *id = controls::controls.at(k);
+ ret.try_emplace(id, controlValueToPy(v));
}
return ret;
Expose the newly introduced `MetadataList` for any given `Request`. This done similarly to the `Request::metadata()`, using the same `controlValueToPy()` function. However, that function is changed to accept `ControlValueView` as its argument since `MetadataList` does not contain `ControlValue`s directly. Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> --- src/py/libcamera/py_helpers.cpp | 4 ++-- src/py/libcamera/py_helpers.h | 2 +- src/py/libcamera/py_main.cpp | 9 ++++----- 3 files changed, 7 insertions(+), 8 deletions(-)