[{"id":12638,"web_url":"https://patchwork.libcamera.org/comment/12638/","msgid":"<20200922113054.GH8290@pendragon.ideasonboard.com>","date":"2020-09-22T11:30:54","subject":"Re: [libcamera-devel] [PATCH 6/6] qcam: Add command line option to\n\ttest IspCrop control","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi David,\n\nThank you for the patch.\n\nOn Tue, Sep 22, 2020 at 11:04:00AM +0100, David Plowman wrote:\n> This allows the user to request digital zoom by adding, for example,\n> \"-z 0.25,0.25,0.5,0.5\" which would give a 2x zoom, still centred in\n> the middle of the image.\n> \n> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n\nA command line option would make more sense for the cam application I\nthink. In qcam, I would rather like to have the zoom integrated in the\nUI. Is this something you would be interested in developing, or should I\ntry to appoint a volunteer ? :-)\n\n> ---\n>  src/qcam/main.cpp        |  3 +++\n>  src/qcam/main_window.cpp | 20 ++++++++++++++++++++\n>  src/qcam/main_window.h   |  1 +\n>  3 files changed, 24 insertions(+)\n> \n> diff --git a/src/qcam/main.cpp b/src/qcam/main.cpp\n> index f60d3ce..9f8435d 100644\n> --- a/src/qcam/main.cpp\n> +++ b/src/qcam/main.cpp\n> @@ -38,6 +38,9 @@ OptionsParser::Options parseOptions(int argc, char *argv[])\n>  \t\t\t \"renderer\", ArgumentRequired, \"renderer\");\n>  \tparser.addOption(OptStream, &streamKeyValue,\n>  \t\t\t \"Set configuration of a camera stream\", \"stream\", true);\n> +\tparser.addOption(OptZoom, OptionString,\n> +\t\t\t \"Specify crop for digital zoom as fractions x,y,width,height e.g. 0.25,0.25,0.5,0.5\",\n> +\t\t\t \"zoom\", ArgumentRequired, \"zoom\");\n>  \n>  \tOptionsParser::Options options = parser.parse(argc, argv);\n>  \tif (options.isSet(OptHelp))\n> diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\n> index 985743f..fb54b15 100644\n> --- a/src/qcam/main_window.cpp\n> +++ b/src/qcam/main_window.cpp\n> @@ -25,6 +25,8 @@\n>  #include <QtDebug>\n>  \n>  #include <libcamera/camera_manager.h>\n> +#include <libcamera/control_ids.h>\n> +#include <libcamera/property_ids.h>\n>  #include <libcamera/version.h>\n>  \n>  #include \"dng_writer.h\"\n> @@ -502,6 +504,24 @@ int MainWindow::startCapture()\n>  \t\trequests.push_back(request);\n>  \t}\n>  \n> +\t/* Set up digital zoom if it was requested on the command line. */\n> +\tif (options_.isSet(OptZoom)) {\n> +\t\tstd::string zoom = options_[OptZoom].toString();\n> +\t\tfloat x, y, width, height;\n> +\n> +\t\tif (sscanf(zoom.c_str(), \"%f,%f,%f,%f\", &x, &y, &width, &height) == 4) {\n> +\t\t\tSize sensorArea = camera_->properties().get(properties::SensorOutputSize);\n> +\t\t\tRectangle crop(x * sensorArea.width,\n> +\t\t\t\t       y * sensorArea.height,\n> +\t\t\t\t       width * sensorArea.width,\n> +\t\t\t\t       height * sensorArea.height);\n> +\n> +\t\t\trequests.front()->controls().set(controls::IspCrop, crop);\n> +\t\t} else {\n> +\t\t\tqWarning() << \"Invalid zoom values - ignoring\";\n> +\t\t}\n> +\t}\n> +\n>  \t/* Start the title timer and the camera. */\n>  \ttitleTimer_.start(2000);\n>  \tframeRateInterval_.start();\n> diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h\n> index 5c61a4d..e46eb70 100644\n> --- a/src/qcam/main_window.h\n> +++ b/src/qcam/main_window.h\n> @@ -39,6 +39,7 @@ enum {\n>  \tOptHelp = 'h',\n>  \tOptRenderer = 'r',\n>  \tOptStream = 's',\n> +\tOptZoom = 'z',\n>  };\n>  \n>  class CaptureRequest","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 08BF6BF01C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 22 Sep 2020 11:31:29 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 766CD62FD4;\n\tTue, 22 Sep 2020 13:31:28 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BE19A60366\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 22 Sep 2020 13:31:27 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 3BADD2D7;\n\tTue, 22 Sep 2020 13:31:27 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"l1yH6RIn\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1600774287;\n\tbh=FyQJdrEOev0JCxkLoDuHibY3kANpp0uz+65HoevbL6E=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=l1yH6RInxw/7Q3YT0MIG3Eafb3aUXWQxUX0dB+aB3Kv1n2ZiECJCPYejXMQgYUFdJ\n\tj7VXohXh+JdE6Srd1WqzTqzQyVsT/3nvSZ3lxfTxp1BpCNlKCUEDaeSzXGV2+mS68a\n\tdQJAPkToPvUQe7sAkIHBQqRpo54C/mjcQiMPuB8I=","Date":"Tue, 22 Sep 2020 14:30:54 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"David Plowman <david.plowman@raspberrypi.com>","Message-ID":"<20200922113054.GH8290@pendragon.ideasonboard.com>","References":"<20200922100400.30766-1-david.plowman@raspberrypi.com>\n\t<20200922100400.30766-7-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200922100400.30766-7-david.plowman@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH 6/6] qcam: Add command line option to\n\ttest IspCrop control","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":12643,"web_url":"https://patchwork.libcamera.org/comment/12643/","msgid":"<CAHW6GYLLdm7hX9UJgBCwif04sSDKt22p_JHJ4WgcvtdoWcdaqg@mail.gmail.com>","date":"2020-09-22T15:25:51","subject":"Re: [libcamera-devel] [PATCH 6/6] qcam: Add command line option to\n\ttest IspCrop control","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"content":"Hi Laurent\n\nThanks for the reply!\n\nOn Tue, 22 Sep 2020 at 12:31, Laurent Pinchart\n<laurent.pinchart@ideasonboard.com> wrote:\n>\n> Hi David,\n>\n> Thank you for the patch.\n>\n> On Tue, Sep 22, 2020 at 11:04:00AM +0100, David Plowman wrote:\n> > This allows the user to request digital zoom by adding, for example,\n> > \"-z 0.25,0.25,0.5,0.5\" which would give a 2x zoom, still centred in\n> > the middle of the image.\n> >\n> > Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n>\n> A command line option would make more sense for the cam application I\n> think. In qcam, I would rather like to have the zoom integrated in the\n> UI. Is this something you would be interested in developing, or should I\n> try to appoint a volunteer ? :-)\n\nWith my knowledge of Qt being non-existent you might have more luck\nwith another volunteer. However, it sounds like it might be worthwhile\nconverting my qcam patch into a cam patch instead. I'll wait a couple\nof days and see if there's any more feedback but then I'll send a v2\nwith that change.\n\nThanks!\nDavid\n\n>\n> > ---\n> >  src/qcam/main.cpp        |  3 +++\n> >  src/qcam/main_window.cpp | 20 ++++++++++++++++++++\n> >  src/qcam/main_window.h   |  1 +\n> >  3 files changed, 24 insertions(+)\n> >\n> > diff --git a/src/qcam/main.cpp b/src/qcam/main.cpp\n> > index f60d3ce..9f8435d 100644\n> > --- a/src/qcam/main.cpp\n> > +++ b/src/qcam/main.cpp\n> > @@ -38,6 +38,9 @@ OptionsParser::Options parseOptions(int argc, char *argv[])\n> >                        \"renderer\", ArgumentRequired, \"renderer\");\n> >       parser.addOption(OptStream, &streamKeyValue,\n> >                        \"Set configuration of a camera stream\", \"stream\", true);\n> > +     parser.addOption(OptZoom, OptionString,\n> > +                      \"Specify crop for digital zoom as fractions x,y,width,height e.g. 0.25,0.25,0.5,0.5\",\n> > +                      \"zoom\", ArgumentRequired, \"zoom\");\n> >\n> >       OptionsParser::Options options = parser.parse(argc, argv);\n> >       if (options.isSet(OptHelp))\n> > diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\n> > index 985743f..fb54b15 100644\n> > --- a/src/qcam/main_window.cpp\n> > +++ b/src/qcam/main_window.cpp\n> > @@ -25,6 +25,8 @@\n> >  #include <QtDebug>\n> >\n> >  #include <libcamera/camera_manager.h>\n> > +#include <libcamera/control_ids.h>\n> > +#include <libcamera/property_ids.h>\n> >  #include <libcamera/version.h>\n> >\n> >  #include \"dng_writer.h\"\n> > @@ -502,6 +504,24 @@ int MainWindow::startCapture()\n> >               requests.push_back(request);\n> >       }\n> >\n> > +     /* Set up digital zoom if it was requested on the command line. */\n> > +     if (options_.isSet(OptZoom)) {\n> > +             std::string zoom = options_[OptZoom].toString();\n> > +             float x, y, width, height;\n> > +\n> > +             if (sscanf(zoom.c_str(), \"%f,%f,%f,%f\", &x, &y, &width, &height) == 4) {\n> > +                     Size sensorArea = camera_->properties().get(properties::SensorOutputSize);\n> > +                     Rectangle crop(x * sensorArea.width,\n> > +                                    y * sensorArea.height,\n> > +                                    width * sensorArea.width,\n> > +                                    height * sensorArea.height);\n> > +\n> > +                     requests.front()->controls().set(controls::IspCrop, crop);\n> > +             } else {\n> > +                     qWarning() << \"Invalid zoom values - ignoring\";\n> > +             }\n> > +     }\n> > +\n> >       /* Start the title timer and the camera. */\n> >       titleTimer_.start(2000);\n> >       frameRateInterval_.start();\n> > diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h\n> > index 5c61a4d..e46eb70 100644\n> > --- a/src/qcam/main_window.h\n> > +++ b/src/qcam/main_window.h\n> > @@ -39,6 +39,7 @@ enum {\n> >       OptHelp = 'h',\n> >       OptRenderer = 'r',\n> >       OptStream = 's',\n> > +     OptZoom = 'z',\n> >  };\n> >\n> >  class CaptureRequest\n>\n> --\n> Regards,\n>\n> Laurent Pinchart","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 5FDA0C3B5C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 22 Sep 2020 15:26:05 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B911462FDA;\n\tTue, 22 Sep 2020 17:26:04 +0200 (CEST)","from mail-ot1-x32d.google.com (mail-ot1-x32d.google.com\n\t[IPv6:2607:f8b0:4864:20::32d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E3F2360576\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 22 Sep 2020 17:26:03 +0200 (CEST)","by mail-ot1-x32d.google.com with SMTP id m12so16024506otr.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 22 Sep 2020 08:26:03 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"K6j2OCvb\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=VGtprR4M8vZRK5xDF56ufT8dIvS0lTmsR/XArrIBTZQ=;\n\tb=K6j2OCvbvLNFKV8wPP0Fx4s5uVAvsViz8drcDzNp/9HMloywvdxH1FZVOT5jls+jdV\n\tSXPh8vlSVob0/tkp8BVQN1dRxm3zNfhEHCClVcNiXE98PevN+us4NNRHDeVXcISnbzk3\n\tA0epn5j7sGLG4dm3jd7EOv18Q1QtPE1tQuDM8sk/6JO9MbqwwVOJoyJeY119wWZkm97H\n\tiho9EyDhivcryDnxeelthrQeCl7tFpOCFwWH4q1In1Oit/0w9x6zU1NsHJMvDxQiXDVP\n\tzHicpMauGGfDM7cUn7lOZz3jPkquQzaPfjVkvd1myK7i/vuZFlXoTsEUiDiL7/VXE9Ql\n\t6spg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=VGtprR4M8vZRK5xDF56ufT8dIvS0lTmsR/XArrIBTZQ=;\n\tb=UGSIbI9g32NBS5Ut3hUrLIZUr9G1I77VWErUGvTAUSSW98OFE2fG5WnYMQJQ0ro7xU\n\tPs+HuujvE5IiIVAZLxChp8CzMCXIGA/Jfv3+KJWIT2M7GtY3kUZfL51zYD1u8eyrJnoq\n\t8BLfQCX+4YW5J0WCKmKJ5y6aQ/0dT7eOX/emG227WOirvmvpMgkJ/gz16Jfd8cI986ES\n\tNs0ye86edCBKuU5cE3tguKozGHwis5B5yySjCXRjstN9Ius+9EOpbbgSmMxQDdINrRC8\n\tK+yd3nCtBenzgw1sudYO06uMOxwELUoe/Oyee8FJwphCpn/EQDvPPRH5oWvQJV1Hv5lB\n\tctFQ==","X-Gm-Message-State":"AOAM5334ulFqwekub6MJD3l4EbJvQUyMsodtbSP/SWKFPFU+2b+c6EcH\n\t28U9H8N4TNAPlvNH5j6WEW0+EbyEvDPZ/AaDLHAcHHfiCfs=","X-Google-Smtp-Source":"ABdhPJwM3VgRFkFJag+OykNeXVsZLFtb1TPpMU07Hy5U4xD3cO5TpTspXRY5xvpJ6Pv2GY5DVSDS8vCQhuCutjqr304=","X-Received":"by 2002:a9d:4c0a:: with SMTP id\n\tl10mr3128831otf.166.1600788361969; \n\tTue, 22 Sep 2020 08:26:01 -0700 (PDT)","MIME-Version":"1.0","References":"<20200922100400.30766-1-david.plowman@raspberrypi.com>\n\t<20200922100400.30766-7-david.plowman@raspberrypi.com>\n\t<20200922113054.GH8290@pendragon.ideasonboard.com>","In-Reply-To":"<20200922113054.GH8290@pendragon.ideasonboard.com>","From":"David Plowman <david.plowman@raspberrypi.com>","Date":"Tue, 22 Sep 2020 16:25:51 +0100","Message-ID":"<CAHW6GYLLdm7hX9UJgBCwif04sSDKt22p_JHJ4WgcvtdoWcdaqg@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 6/6] qcam: Add command line option to\n\ttest IspCrop control","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]