{"id":8713,"url":"https://patchwork.libcamera.org/api/1.1/patches/8713/?format=json","web_url":"https://patchwork.libcamera.org/patch/8713/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20200709091555.1617-2-david.plowman@raspberrypi.com>","date":"2020-07-09T09:15:54","name":"[libcamera-devel,v2,1/2] libcamera: Implement digital zoom","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"19ef439579f1401fb1fbce98b689201ab9ffb61a","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/1.1/people/42/?format=json","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/8713/mbox/","series":[{"id":1092,"url":"https://patchwork.libcamera.org/api/1.1/series/1092/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1092","date":"2020-07-09T09:15:53","name":"Digital zoom implementation","version":2,"mbox":"https://patchwork.libcamera.org/series/1092/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/8713/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/8713/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 2096FBD790\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  9 Jul 2020 09:16:09 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DD72C611AD;\n\tThu,  9 Jul 2020 11:16:08 +0200 (CEST)","from mail-wm1-x342.google.com (mail-wm1-x342.google.com\n\t[IPv6:2a00:1450:4864:20::342])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4CF0561186\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  9 Jul 2020 11:16:07 +0200 (CEST)","by mail-wm1-x342.google.com with SMTP id l2so1066837wmf.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 09 Jul 2020 02:16:07 -0700 (PDT)","from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72])\n\tby smtp.gmail.com with ESMTPSA id\n\th84sm4135765wme.22.2020.07.09.02.16.05\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 09 Jul 2020 02:16:06 -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=\"EkCT+/If\"; 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=JxYFmoILtnLrUDRRdBNhPp9I1szEqxBDjAjdoZD8Yc8=;\n\tb=EkCT+/If0EbTWmiIExd9SY0UDzEE6WDOMyCJYjROBuXSmvhWV0sFKN7zz4U9q/hY+M\n\t5XXF6DyQtGjWkvUY9s11ekg2tua9m3kAde1HckeRkA+o0/KsA5q3yv2eYBXmNAgxGoaZ\n\tQnia4sq+XbYToDv5DeDLc4DQCNJRPmkog5DBsiqflg2QyRIcYomVLekXal5AiWptKWnb\n\teU0qbxBo4Gb9u4ScQRUnOTrUF/nkmYWQjdrBApSlCtIDtKAG3y9WB1BfFjhCWBJotJy3\n\tR8MuTSTfKaF5PNfg511hlUfdnlvrNjz66mBtAQhPcPw4na8pRmraKhTNk/GtAjf9SXeG\n\t1wMg==","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=JxYFmoILtnLrUDRRdBNhPp9I1szEqxBDjAjdoZD8Yc8=;\n\tb=baJvQs45fR65oMrfVoDNA+7aQURWnn0C+joiaJNtSDuQwvm9MgoWn5Xh6+Z6R4VYED\n\taBZxHiF3D0TGef61fW1Yq/PAq7TQc+ETyFIPzERbCl6Tm6KcjHhdsm87grREP1D1yG1b\n\teXZko+CdX9JgY15ZjPw5bO27llIaBts7kNPELr7WbDLwQZTKEx+0DAnwE5YPyvWGlCKU\n\tN6gVGOiFGwYG08CeI6e3Ojk9w8xYqhDH+UETr9B8KFUTGOWIL18YMu+E8AmxOVKtluLL\n\tzbiAN6U6X3zxhBgBgw2BckSvWyi26qTS+5HYXIQ+xUouuhU5IQCN57UMQm3cFt5gp1ld\n\tur9Q==","X-Gm-Message-State":"AOAM530RURtJpAhmb3jZd9KUUcgPOTJwWQJgLhuRFhBdZPbTI+oE5qWY\n\tQR7G/JdLatVAwydMtxVY6xH4v2PagFU=","X-Google-Smtp-Source":"ABdhPJxYVCJylPo/gu6YJ9S53LEOlhm+Ap35Gn7mWejRAZo0obEfhiGukTI/OoAIpOFZ6pXq56zUBA==","X-Received":"by 2002:a1c:7706:: with SMTP id t6mr12538569wmi.3.1594286166652; \n\tThu, 09 Jul 2020 02:16:06 -0700 (PDT)","From":"David Plowman <david.plowman@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu,  9 Jul 2020 10:15:54 +0100","Message-Id":"<20200709091555.1617-2-david.plowman@raspberrypi.com>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20200709091555.1617-1-david.plowman@raspberrypi.com>","References":"<20200709091555.1617-1-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v2 1/2] libcamera: Implement digital zoom","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":"These changes add a Digital Zoom control, tacking a rectangle as its\nargument, indicating the region of the sensor output that will be\nzoomed up to the final output size.\n\nAdditionally, we need have a method returning the \"sensorCrop\" which\ngives the dimensions of the sensor output within which we can pan and\nzoom.\n---\n include/libcamera/camera.h                    |  2 ++\n include/libcamera/internal/pipeline_handler.h |  4 +++\n src/libcamera/camera.cpp                      | 26 +++++++++++++++++++\n src/libcamera/control_ids.yaml                | 10 +++++++\n 4 files changed, 42 insertions(+)","diff":"diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h\nindex 4d1a4a9..dd07f7a 100644\n--- a/include/libcamera/camera.h\n+++ b/include/libcamera/camera.h\n@@ -92,6 +92,8 @@ public:\n \tstd::unique_ptr<CameraConfiguration> generateConfiguration(const StreamRoles &roles = {});\n \tint configure(CameraConfiguration *config);\n \n+\tSize const &getSensorCrop() const;\n+\n \tRequest *createRequest(uint64_t cookie = 0);\n \tint queueRequest(Request *request);\n \ndiff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h\nindex 22e629a..37e069a 100644\n--- a/include/libcamera/internal/pipeline_handler.h\n+++ b/include/libcamera/internal/pipeline_handler.h\n@@ -89,6 +89,8 @@ public:\n \n \tconst char *name() const { return name_; }\n \n+\tSize const &getSensorCrop() const { return sensorCrop_; }\n+\n protected:\n \tvoid registerCamera(std::shared_ptr<Camera> camera,\n \t\t\t    std::unique_ptr<CameraData> data);\n@@ -100,6 +102,8 @@ protected:\n \n \tCameraManager *manager_;\n \n+\tSize sensorCrop_;\n+\n private:\n \tvoid mediaDeviceDisconnected(MediaDevice *media);\n \tvirtual void disconnect();\ndiff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\nindex 69a1b44..6614c93 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -793,6 +793,32 @@ int Camera::configure(CameraConfiguration *config)\n \treturn 0;\n }\n \n+/**\n+ * \\brief Return the size of the sensor image being used to form the output\n+ *\n+ * This method returns the size, in pixels, of the raw image read from the\n+ * sensor and which is used to form the output image(s). Note that these\n+ * values take account of any cropping performed on the sensor output so\n+ * as to produce the correct aspect ratio. It would normally be necessary\n+ * to retrieve these values in order to calculate correct parameters for\n+ * digital zoom.\n+ *\n+ * Example: a sensor mode may produce a 1920x1440 output image. But if an\n+ * application has requested a 16:9 image, the values returned here would\n+ * be 1920x1080 - the largest portion of the sensor output that provides\n+ * the correct aspect ratio.\n+ *\n+ * \\context This function is \\threadsafe. It will only return valid\n+ * (non-zero) values when the camera has been configured.\n+ *\n+ * \\return The dimensions of the sensor image in use.\n+ */\n+\n+Size const &Camera::getSensorCrop() const\n+{\n+\treturn p_->pipe_->getSensorCrop();\n+}\n+\n /**\n  * \\brief Create a request object for the camera\n  * \\param[in] cookie Opaque cookie for application use\ndiff --git a/src/libcamera/control_ids.yaml b/src/libcamera/control_ids.yaml\nindex 988b501..5a099d5 100644\n--- a/src/libcamera/control_ids.yaml\n+++ b/src/libcamera/control_ids.yaml\n@@ -262,4 +262,14 @@ controls:\n         In this respect, it is not necessarily aimed at providing a way to\n         implement a focus algorithm by the application, rather an indication of\n         how in-focus a frame is.\n+\n+  - DigitalZoom:\n+      type: Rectangle\n+      description: |\n+        Sets the portion of the full sensor image, in pixels, that will be\n+        used for digital zoom. That is, this part of the sensor output will\n+        be scaled up to make the full size output image (and everything else\n+        discarded). To obtain the \"full sensor image\" that is available, the\n+        method Camera::getOutputCrop() should be called once the camera is\n+        configured. An application may pan and zoom within this rectangle.\n ...\n","prefixes":["libcamera-devel","v2","1/2"]}