Message ID | 20221208134414.2917-1-david.plowman@raspberrypi.com |
---|---|
State | Accepted |
Commit | a6b1ff2e6caa632fe041e3eae569acb861e3353b |
Headers | show |
Series |
|
Related | show |
Hi David, Thank you for your patch. On Thu, 8 Dec 2022 at 13:44, David Plowman via libcamera-devel < libcamera-devel@lists.libcamera.org> wrote: > The Python bindings will now accept, or return, a list or tuple of > libcamera.Rectangle objects for such controls. > > This had previously been omitted, but now we have, for example, the > AfWindows control which requires this feature. > > Signed-off-by: David Plowman <david.plowman@raspberrypi.com> > Reviewed-by: Naushir Patuck <naush@raspberrypi.com> > --- > src/py/libcamera/py_helpers.cpp | 8 +++----- > 1 file changed, 3 insertions(+), 5 deletions(-) > > diff --git a/src/py/libcamera/py_helpers.cpp > b/src/py/libcamera/py_helpers.cpp > index f685e606..79891ab6 100644 > --- a/src/py/libcamera/py_helpers.cpp > +++ b/src/py/libcamera/py_helpers.cpp > @@ -46,10 +46,8 @@ py::object controlValueToPy(const ControlValue &cv) > return valueOrTuple<float>(cv); > case ControlTypeString: > return py::cast(cv.get<std::string>()); > - case ControlTypeRectangle: { > - const Rectangle *v = reinterpret_cast<const Rectangle > *>(cv.data().data()); > - return py::cast(v); > - } > + case ControlTypeRectangle: > + return valueOrTuple<Rectangle>(cv); > case ControlTypeSize: { > const Size *v = reinterpret_cast<const Size > *>(cv.data().data()); > return py::cast(v); > @@ -88,7 +86,7 @@ ControlValue pyToControlValue(const py::object &ob, > ControlType type) > case ControlTypeString: > return ControlValue(ob.cast<std::string>()); > case ControlTypeRectangle: > - return ControlValue(ob.cast<Rectangle>()); > + return controlValueMaybeArray<Rectangle>(ob); > case ControlTypeSize: > return ControlValue(ob.cast<Size>()); > case ControlTypeNone: > -- > 2.30.2 > >
On 08/12/2022 15:44, David Plowman via libcamera-devel wrote: > The Python bindings will now accept, or return, a list or tuple of > libcamera.Rectangle objects for such controls. > > This had previously been omitted, but now we have, for example, the > AfWindows control which requires this feature. > > Signed-off-by: David Plowman <david.plowman@raspberrypi.com> > --- Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Tomi
diff --git a/src/py/libcamera/py_helpers.cpp b/src/py/libcamera/py_helpers.cpp index f685e606..79891ab6 100644 --- a/src/py/libcamera/py_helpers.cpp +++ b/src/py/libcamera/py_helpers.cpp @@ -46,10 +46,8 @@ py::object controlValueToPy(const ControlValue &cv) return valueOrTuple<float>(cv); case ControlTypeString: return py::cast(cv.get<std::string>()); - case ControlTypeRectangle: { - const Rectangle *v = reinterpret_cast<const Rectangle *>(cv.data().data()); - return py::cast(v); - } + case ControlTypeRectangle: + return valueOrTuple<Rectangle>(cv); case ControlTypeSize: { const Size *v = reinterpret_cast<const Size *>(cv.data().data()); return py::cast(v); @@ -88,7 +86,7 @@ ControlValue pyToControlValue(const py::object &ob, ControlType type) case ControlTypeString: return ControlValue(ob.cast<std::string>()); case ControlTypeRectangle: - return ControlValue(ob.cast<Rectangle>()); + return controlValueMaybeArray<Rectangle>(ob); case ControlTypeSize: return ControlValue(ob.cast<Size>()); case ControlTypeNone:
The Python bindings will now accept, or return, a list or tuple of libcamera.Rectangle objects for such controls. This had previously been omitted, but now we have, for example, the AfWindows control which requires this feature. Signed-off-by: David Plowman <david.plowman@raspberrypi.com> --- src/py/libcamera/py_helpers.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)