{"id":8936,"url":"https://patchwork.libcamera.org/api/patches/8936/?format=json","web_url":"https://patchwork.libcamera.org/patch/8936/","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":"<20200723084338.13711-2-david.plowman@raspberrypi.com>","date":"2020-07-23T08:43:37","name":"[libcamera-devel,v3,1/2] libcamera: Infrastructure for digital zoom","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"850e50aed27b9d7f154ed205e26c47dc1ebf0b9c","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/8936/mbox/","series":[{"id":1129,"url":"https://patchwork.libcamera.org/api/series/1129/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1129","date":"2020-07-23T08:43:36","name":"Digital zoom implementatino","version":3,"mbox":"https://patchwork.libcamera.org/series/1129/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/8936/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/8936/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 CC1B0BD86F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 23 Jul 2020 08:43:46 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9B6016112A;\n\tThu, 23 Jul 2020 10:43:46 +0200 (CEST)","from mail-wm1-x344.google.com (mail-wm1-x344.google.com\n\t[IPv6:2a00:1450:4864:20::344])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3373B60939\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 Jul 2020 10:43:44 +0200 (CEST)","by mail-wm1-x344.google.com with SMTP id o8so4197075wmh.4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 Jul 2020 01:43:44 -0700 (PDT)","from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72])\n\tby smtp.gmail.com with ESMTPSA id\n\tt2sm2809450wmb.25.2020.07.23.01.43.42\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 23 Jul 2020 01:43:43 -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=\"QH68CWdb\"; 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=fucOP9zskuOzWC8DYYa7syEbPMpQ+PXRcZIhZYYEiFY=;\n\tb=QH68CWdb37u8QXTAW4pIh2VJA+nrPJToR/P3GtDPBmpssEZ6eVuUySYbsxHqkZAVSZ\n\tyg+So5vi79Mk4tTunxREyWq1MUvlUaPATR91ZG55k0lMgdR7xrkLLSYXm8cyOirPk56N\n\tJr/12PkUR0BLMQTc7rdvsyU2OWRDymseEGoR/sXaH/vlro4/3GIs9PLHh6vRY4IppvC0\n\tb7xVDAOSWPwOwyE7BRt1Ja7UmdbgDiSY/TbCPew4Vb8z0KQI/uiKbI/XOLlc9Y08BOxv\n\t796frSh3LbgQh3BM/NOd3HXTWmQx5J14lF+e1DuXnHeGw9bTLuS1c9+IEkUIrcY91Z7o\n\tVraA==","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=fucOP9zskuOzWC8DYYa7syEbPMpQ+PXRcZIhZYYEiFY=;\n\tb=rYbhYujfzFgqxPj3St2OM2R+bH96hrd4kLl/fX/7FCRgFngPot0sEmJhfAECB4Q3po\n\tcelF48rmGNiIQcPDIT6sY+eKfytdSpQu8/BHph+d0ZOWxyRCZlUAxVD9u5agS17jrLb2\n\t6zz2GG/2HFRvGJmi5m7qPvn5fafZD3rOvnEp+xdNuU4EVfCcmjpKJJAoXNlP/lSn2qSS\n\tEjyocbjcP7K5sFALgtUnMjDjlIcgE1dbVmlSRv4VjVkkKUCCVhtIfOqe6hjHESNWbFrm\n\tPkjbBfYCDp7wPE60UuCD1WfdCAij1KcIxXdqsuMJABiBfcZZcVXmANzMk8cx+KGZijow\n\t/NPw==","X-Gm-Message-State":"AOAM530CYFoAhjNnz1M8uUdHxOWqro3IdipMHXgTUeMntPdfgZPlA+z/\n\tDmiN+jxKTRT2lCqSHiRKYPS9Ou/o3ES27g==","X-Google-Smtp-Source":"ABdhPJzXMcT/2zSW/WfITTmf1YN3+kEGmfFlFpwwEFZK/1Ug1YoXFl9Xwj3O0zWEU4Q5HSrUJxFaow==","X-Received":"by 2002:a1c:ed01:: with SMTP id l1mr3240685wmh.33.1595493823543; \n\tThu, 23 Jul 2020 01:43:43 -0700 (PDT)","From":"David Plowman <david.plowman@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu, 23 Jul 2020 09:43:37 +0100","Message-Id":"<20200723084338.13711-2-david.plowman@raspberrypi.com>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20200723084338.13711-1-david.plowman@raspberrypi.com>","References":"<20200723084338.13711-1-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v3 1/2] libcamera: Infrastructure for\n\tdigital 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, taking a rectangle as its\nargument, indicating the region of the sensor output that the\npipeline will \"zoom up\" to the final output size.\n\nAdditionally, we need to have a method returning the \"pipelineCrop\"\nwhich gives the dimensions of the sensor output, taken by the\npipeline, and within which we can subsequently pan and zoom.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\n---\n include/libcamera/camera.h                    |  2 ++\n include/libcamera/internal/pipeline_handler.h |  4 +++\n src/libcamera/camera.cpp                      | 27 +++++++++++++++++++\n src/libcamera/control_ids.yaml                | 10 +++++++\n 4 files changed, 43 insertions(+)","diff":"diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h\nindex 4d1a4a9..6819b8e 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 &getPipelineCrop() 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..5bfe890 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 &getPipelineCrop() const { return pipelineCrop_; }\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 pipelineCrop_;\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..f8b8ec6 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -793,6 +793,33 @@ int Camera::configure(CameraConfiguration *config)\n \treturn 0;\n }\n \n+/**\n+ * \\brief Return the size of the sensor image being used by the pipeline\n+ * to create the output.\n+ *\n+ * This method returns the size, in pixels, of the raw image read from the\n+ * sensor and which is used by the pipeline to form the output image(s)\n+ * (rescaling if necessary). Note that these values take account of any\n+ * cropping performed on the sensor output so as to produce the correct\n+ * aspect ratio. It would normally be necessary to retrieve these values\n+ * in order to calculate correct parameters for 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 might\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 used by the pipeline.\n+ */\n+\n+Size const &Camera::getPipelineCrop() const\n+{\n+\treturn p_->pipe_->getPipelineCrop();\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","v3","1/2"]}