[PATCH] cam: capture_script: Make parseRectangles work for non-array

Umang Jain umang.jain at ideasonboard.com
Fri Mar 8 14:28:49 CET 2024


Hi Jacopo

On 08/03/24 4:12 pm, Jacopo Mondi wrote:
> From: Paul Elder <paul.elder at ideasonboard.com>
>
> parseRectangles currently always parses Rectangle controls as an array

nit: s/parseRectangles/parseRectangles()/
> of Rectangles. This causes non-array Rectangle controls to not be parsed
> correctly, as when the ControlValue is get()ed, the non-array assertion
> will fail.
>
> Set the ControlValue with a single Rectangle in case a single Rectangle
> has been specified in the yaml capture script to fix that.
>
> Signed-off-by: Paul Elder <paul.elder at ideasonboard.com>
> Signed-off-by: Jacopo Mondi <jacopo.mondi at ideasonboard.com>
LGTM

Reviewed-by: Umang Jain <umang.jain at ideasonboard.com>

> ---
>   src/apps/cam/capture_script.cpp | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/src/apps/cam/capture_script.cpp b/src/apps/cam/capture_script.cpp
> index 062a7258e414..1215713fac18 100644
> --- a/src/apps/cam/capture_script.cpp
> +++ b/src/apps/cam/capture_script.cpp
> @@ -351,7 +351,10 @@ ControlValue CaptureScript::parseRectangles()
>   	}
>   
>   	ControlValue controlValue;
> -	controlValue.set(Span<const Rectangle>(rectangles));
> +	if (rectangles.size() == 1)
> +		controlValue.set(rectangles.at(0));
> +	else
> +		controlValue.set(Span<const Rectangle>(rectangles));
>   
>   	return controlValue;
>   }



More information about the libcamera-devel mailing list