[libcamera-devel] [PATCH v7 12/13] py: add support for setting Rectangle and Size controls
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Thu May 5 20:03:19 CEST 2022
Hi Tomi and David,
Thank you for the patch.
On Thu, May 05, 2022 at 01:41:03PM +0300, Tomi Valkeinen wrote:
> From: David Plowman <david.plowman at raspberrypi.com>
>
> Allows, for example, ScalerCrop to be controlled for digital zoom.
>
> Signed-off-by: David Plowman <david.plowman at raspberrypi.com>
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen at ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> ---
> src/py/libcamera/pymain.cpp | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/src/py/libcamera/pymain.cpp b/src/py/libcamera/pymain.cpp
> index 6375e326..b9b52f6b 100644
> --- a/src/py/libcamera/pymain.cpp
> +++ b/src/py/libcamera/pymain.cpp
> @@ -101,8 +101,14 @@ static ControlValue PyToControlValue(const py::object &ob, ControlType type)
> return ControlValueMaybeArray<float>(ob);
> case ControlTypeString:
> return ControlValue(ob.cast<string>());
> - case ControlTypeRectangle:
> - case ControlTypeSize:
> + case ControlTypeRectangle: {
> + auto array = ob.cast<std::array<int32_t, 4>>();
> + return ControlValue(Rectangle(array[0], array[1], array[2], array[3]));
> + }
> + case ControlTypeSize: {
> + auto array = ob.cast<std::array<int32_t, 2>>();
> + return ControlValue(Size(array[0], array[1]));
> + }
> case ControlTypeNone:
> default:
> throw runtime_error("Control type not implemented");
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list