{"id":9869,"url":"https://patchwork.libcamera.org/api/patches/9869/?format=json","web_url":"https://patchwork.libcamera.org/patch/9869/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20200929164000.15429-7-david.plowman@raspberrypi.com>","date":"2020-09-29T16:40:00","name":"[libcamera-devel,v3,6/6] cam: Add command line option to test IspCrop control","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"f4a1fcbb4b51b4b483b7f6b2c017e85441f90edf","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/?format=json","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/9869/mbox/","series":[{"id":1337,"url":"https://patchwork.libcamera.org/api/series/1337/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1337","date":"2020-09-29T16:39:54","name":"Digital zoom","version":3,"mbox":"https://patchwork.libcamera.org/series/1337/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/9869/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/9869/checks/","tags":{},"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 BA482C3B5B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 29 Sep 2020 16:40:14 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7B2706221F;\n\tTue, 29 Sep 2020 18:40:14 +0200 (CEST)","from mail-wr1-x433.google.com (mail-wr1-x433.google.com\n\t[IPv6:2a00:1450:4864:20::433])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0D68A62211\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 29 Sep 2020 18:40:11 +0200 (CEST)","by mail-wr1-x433.google.com with SMTP id z4so6185050wrr.4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 29 Sep 2020 09:40:11 -0700 (PDT)","from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72])\n\tby smtp.gmail.com with ESMTPSA id\n\tq12sm6977393wrs.48.2020.09.29.09.40.09\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 29 Sep 2020 09:40:09 -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=\"lVa87LLF\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=WDoEdN80X2fj4rhVFmRDdDnGzuHzhrvAaQt+7lJP83w=;\n\tb=lVa87LLFzTT3HPK4FkFoSCyIEaruvxMSXDxHwJtkjOLaxeJCYlQUQvHusA7pPL8ux7\n\tXWDrGD2lyAfkA/Vvw+TOqwFLuuCbDPZTI3HOeyBZVJWVw9Hesgdpr5s7gDEHx3xukfcx\n\tB3ixrabf6y7s62Me6ccSb2f1nDY5oAZTtlJovPKd1RPC0afU6Bo1CfPB09QD/qzehyEj\n\tDPfZ8UOs8CayPRT3TQ7mvYMPdkCAu/VoW5h8gtHvsos4NuqVWeRyKxEwrUez1aN8FXat\n\tuQssRMgIptZalmCaTs5QcK6/4Bq9ECSIQHIXRw59DsndYGGRBwcYu1mGJd0FcKzVthIj\n\tftEQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=WDoEdN80X2fj4rhVFmRDdDnGzuHzhrvAaQt+7lJP83w=;\n\tb=S8z4uikHr2T4HVl3WotA5uHq8SPTunD8TM+ZVb0iUfMDE1eNLXwp8vQEp+JtppDyiQ\n\tpdnfP/EOqualEQ7xG3jb6raDoVAGwNq+icjp+zALnMg5UexpQDvE4lWnNfVZztQF/hre\n\thB5uB13gcviW7O5Wj0carrvVrFGrnaHCJ5WFts2KmjYgv4WjGRiy9EeCpPJYKZpVj41k\n\tDXY0+jjguGjBu9Vtld6J/x4XdJXD8voI3SHWaULCcCngP9KtrMd73VABnKF0C5xsk8H2\n\thNl1I6mEV9GTQxsCGn9Z3aEPsssjdMwdsRB2n0XkV0Qc3IyajhR9s7Bg1HyZLJ/gLTuU\n\tdmyQ==","X-Gm-Message-State":"AOAM533k9yxY6dYkOR9olf9gwMFj71brmF1Dci1OgxF7ZnM1RHM3nr2D\n\tk+5VnGIoioW3/8DQ2iMLU82+xWshdVQJEg==","X-Google-Smtp-Source":"ABdhPJxM2mGdRI1BAW944mzbsluGJJkR14rX+QpPl4SooH1dm/3//qoleV6SmWGApK8bVdAeUEcuUA==","X-Received":"by 2002:a5d:5404:: with SMTP id g4mr5099203wrv.134.1601397610412;\n\tTue, 29 Sep 2020 09:40:10 -0700 (PDT)","From":"David Plowman <david.plowman@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 29 Sep 2020 17:40:00 +0100","Message-Id":"<20200929164000.15429-7-david.plowman@raspberrypi.com>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20200929164000.15429-1-david.plowman@raspberrypi.com>","References":"<20200929164000.15429-1-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v3 6/6] cam: 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>","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>"},"content":"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\nthe middle of the image.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\n---\n src/cam/capture.cpp | 25 +++++++++++++++++++++++--\n src/cam/capture.h   |  2 +-\n src/cam/main.cpp    |  3 +++\n src/cam/main.h      |  1 +\n 4 files changed, 28 insertions(+), 3 deletions(-)","diff":"diff --git a/src/cam/capture.cpp b/src/cam/capture.cpp\nindex 5510c009..3b50c591 100644\n--- a/src/cam/capture.cpp\n+++ b/src/cam/capture.cpp\n@@ -10,6 +10,9 @@\n #include <limits.h>\n #include <sstream>\n \n+#include <libcamera/control_ids.h>\n+#include <libcamera/property_ids.h>\n+\n #include \"capture.h\"\n #include \"main.h\"\n \n@@ -58,7 +61,7 @@ int Capture::run(const OptionsParser::Options &options)\n \n \tFrameBufferAllocator *allocator = new FrameBufferAllocator(camera_);\n \n-\tret = capture(allocator);\n+\tret = capture(allocator, options);\n \n \tif (options.isSet(OptFile)) {\n \t\tdelete writer_;\n@@ -70,7 +73,7 @@ int Capture::run(const OptionsParser::Options &options)\n \treturn ret;\n }\n \n-int Capture::capture(FrameBufferAllocator *allocator)\n+int Capture::capture(FrameBufferAllocator *allocator, const OptionsParser::Options &options)\n {\n \tint ret;\n \n@@ -120,6 +123,24 @@ int Capture::capture(FrameBufferAllocator *allocator)\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\tstd::cout << \"Invalid zoom values - ignoring\" << std::endl;\n+\t\t}\n+\t}\n+\n \tret = camera_->start();\n \tif (ret) {\n \t\tstd::cout << \"Failed to start capture\" << std::endl;\ndiff --git a/src/cam/capture.h b/src/cam/capture.h\nindex 0aebdac9..52806164 100644\n--- a/src/cam/capture.h\n+++ b/src/cam/capture.h\n@@ -29,7 +29,7 @@ public:\n \n \tint run(const OptionsParser::Options &options);\n private:\n-\tint capture(libcamera::FrameBufferAllocator *allocator);\n+\tint capture(libcamera::FrameBufferAllocator *allocator, const OptionsParser::Options &options);\n \n \tvoid requestComplete(libcamera::Request *request);\n \ndiff --git a/src/cam/main.cpp b/src/cam/main.cpp\nindex 244720b4..b871d049 100644\n--- a/src/cam/main.cpp\n+++ b/src/cam/main.cpp\n@@ -201,6 +201,9 @@ int CamApp::parseOptions(int argc, char *argv[])\n \tparser.addOption(OptStrictFormats, OptionNone,\n \t\t\t \"Do not allow requested stream format(s) to be adjusted\",\n \t\t\t \"strict-formats\");\n+\tparser.addOption(OptZoom, OptionString,\n+\t\t\t \"Zoom in on the image portion described by the x,y,width,height rectangle (fractions of the maximum FOV) e.g. 0.25,0.25,0.5,0.5\",\n+\t\t\t \"zoom\", ArgumentRequired, \"zoom\");\n \n \toptions_ = parser.parse(argc, argv);\n \tif (!options_.valid())\ndiff --git a/src/cam/main.h b/src/cam/main.h\nindex ea8dfd33..a1fd899f 100644\n--- a/src/cam/main.h\n+++ b/src/cam/main.h\n@@ -17,6 +17,7 @@ enum {\n \tOptListProperties = 'p',\n \tOptMonitor = 'm',\n \tOptStream = 's',\n+\tOptZoom = 'z',\n \tOptListControls = 256,\n \tOptStrictFormats = 257,\n };\n","prefixes":["libcamera-devel","v3","6/6"]}