[libcamera-devel] [PATCH 6/6] qcam: Add command line option to test IspCrop control
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Tue Sep 22 13:30:54 CEST 2020
Hi David,
Thank you for the patch.
On Tue, Sep 22, 2020 at 11:04:00AM +0100, David Plowman wrote:
> This allows the user to request digital zoom by adding, for example,
> "-z 0.25,0.25,0.5,0.5" which would give a 2x zoom, still centred in
> the middle of the image.
>
> Signed-off-by: David Plowman <david.plowman at raspberrypi.com>
A command line option would make more sense for the cam application I
think. In qcam, I would rather like to have the zoom integrated in the
UI. Is this something you would be interested in developing, or should I
try to appoint a volunteer ? :-)
> ---
> src/qcam/main.cpp | 3 +++
> src/qcam/main_window.cpp | 20 ++++++++++++++++++++
> src/qcam/main_window.h | 1 +
> 3 files changed, 24 insertions(+)
>
> diff --git a/src/qcam/main.cpp b/src/qcam/main.cpp
> index f60d3ce..9f8435d 100644
> --- a/src/qcam/main.cpp
> +++ b/src/qcam/main.cpp
> @@ -38,6 +38,9 @@ OptionsParser::Options parseOptions(int argc, char *argv[])
> "renderer", ArgumentRequired, "renderer");
> parser.addOption(OptStream, &streamKeyValue,
> "Set configuration of a camera stream", "stream", true);
> + parser.addOption(OptZoom, OptionString,
> + "Specify crop for digital zoom as fractions x,y,width,height e.g. 0.25,0.25,0.5,0.5",
> + "zoom", ArgumentRequired, "zoom");
>
> OptionsParser::Options options = parser.parse(argc, argv);
> if (options.isSet(OptHelp))
> diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
> index 985743f..fb54b15 100644
> --- a/src/qcam/main_window.cpp
> +++ b/src/qcam/main_window.cpp
> @@ -25,6 +25,8 @@
> #include <QtDebug>
>
> #include <libcamera/camera_manager.h>
> +#include <libcamera/control_ids.h>
> +#include <libcamera/property_ids.h>
> #include <libcamera/version.h>
>
> #include "dng_writer.h"
> @@ -502,6 +504,24 @@ int MainWindow::startCapture()
> requests.push_back(request);
> }
>
> + /* Set up digital zoom if it was requested on the command line. */
> + if (options_.isSet(OptZoom)) {
> + std::string zoom = options_[OptZoom].toString();
> + float x, y, width, height;
> +
> + if (sscanf(zoom.c_str(), "%f,%f,%f,%f", &x, &y, &width, &height) == 4) {
> + Size sensorArea = camera_->properties().get(properties::SensorOutputSize);
> + Rectangle crop(x * sensorArea.width,
> + y * sensorArea.height,
> + width * sensorArea.width,
> + height * sensorArea.height);
> +
> + requests.front()->controls().set(controls::IspCrop, crop);
> + } else {
> + qWarning() << "Invalid zoom values - ignoring";
> + }
> + }
> +
> /* Start the title timer and the camera. */
> titleTimer_.start(2000);
> frameRateInterval_.start();
> diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h
> index 5c61a4d..e46eb70 100644
> --- a/src/qcam/main_window.h
> +++ b/src/qcam/main_window.h
> @@ -39,6 +39,7 @@ enum {
> OptHelp = 'h',
> OptRenderer = 'r',
> OptStream = 's',
> + OptZoom = 'z',
> };
>
> class CaptureRequest
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list