From patchwork Thu Jul 9 09:15:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 8713 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 2096FBD790 for ; Thu, 9 Jul 2020 09:16:09 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DD72C611AD; Thu, 9 Jul 2020 11:16:08 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="EkCT+/If"; dkim-atps=neutral Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4CF0561186 for ; Thu, 9 Jul 2020 11:16:07 +0200 (CEST) Received: by mail-wm1-x342.google.com with SMTP id l2so1066837wmf.0 for ; Thu, 09 Jul 2020 02:16:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JxYFmoILtnLrUDRRdBNhPp9I1szEqxBDjAjdoZD8Yc8=; b=EkCT+/If0EbTWmiIExd9SY0UDzEE6WDOMyCJYjROBuXSmvhWV0sFKN7zz4U9q/hY+M 5XXF6DyQtGjWkvUY9s11ekg2tua9m3kAde1HckeRkA+o0/KsA5q3yv2eYBXmNAgxGoaZ Qnia4sq+XbYToDv5DeDLc4DQCNJRPmkog5DBsiqflg2QyRIcYomVLekXal5AiWptKWnb eU0qbxBo4Gb9u4ScQRUnOTrUF/nkmYWQjdrBApSlCtIDtKAG3y9WB1BfFjhCWBJotJy3 R8MuTSTfKaF5PNfg511hlUfdnlvrNjz66mBtAQhPcPw4na8pRmraKhTNk/GtAjf9SXeG 1wMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JxYFmoILtnLrUDRRdBNhPp9I1szEqxBDjAjdoZD8Yc8=; b=baJvQs45fR65oMrfVoDNA+7aQURWnn0C+joiaJNtSDuQwvm9MgoWn5Xh6+Z6R4VYED aBZxHiF3D0TGef61fW1Yq/PAq7TQc+ETyFIPzERbCl6Tm6KcjHhdsm87grREP1D1yG1b eXZko+CdX9JgY15ZjPw5bO27llIaBts7kNPELr7WbDLwQZTKEx+0DAnwE5YPyvWGlCKU N6gVGOiFGwYG08CeI6e3Ojk9w8xYqhDH+UETr9B8KFUTGOWIL18YMu+E8AmxOVKtluLL zbiAN6U6X3zxhBgBgw2BckSvWyi26qTS+5HYXIQ+xUouuhU5IQCN57UMQm3cFt5gp1ld ur9Q== X-Gm-Message-State: AOAM530RURtJpAhmb3jZd9KUUcgPOTJwWQJgLhuRFhBdZPbTI+oE5qWY QR7G/JdLatVAwydMtxVY6xH4v2PagFU= X-Google-Smtp-Source: ABdhPJxYVCJylPo/gu6YJ9S53LEOlhm+Ap35Gn7mWejRAZo0obEfhiGukTI/OoAIpOFZ6pXq56zUBA== X-Received: by 2002:a1c:7706:: with SMTP id t6mr12538569wmi.3.1594286166652; Thu, 09 Jul 2020 02:16:06 -0700 (PDT) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id h84sm4135765wme.22.2020.07.09.02.16.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jul 2020 02:16:06 -0700 (PDT) From: David Plowman 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" These changes add a Digital Zoom control, tacking a rectangle as its argument, indicating the region of the sensor output that will be zoomed up to the final output size. Additionally, we need have a method returning the "sensorCrop" which gives the dimensions of the sensor output within which we can pan and zoom. --- include/libcamera/camera.h | 2 ++ include/libcamera/internal/pipeline_handler.h | 4 +++ src/libcamera/camera.cpp | 26 +++++++++++++++++++ src/libcamera/control_ids.yaml | 10 +++++++ 4 files changed, 42 insertions(+) diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h index 4d1a4a9..dd07f7a 100644 --- a/include/libcamera/camera.h +++ b/include/libcamera/camera.h @@ -92,6 +92,8 @@ public: std::unique_ptr generateConfiguration(const StreamRoles &roles = {}); int configure(CameraConfiguration *config); + Size const &getSensorCrop() const; + Request *createRequest(uint64_t cookie = 0); int queueRequest(Request *request); diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h index 22e629a..37e069a 100644 --- a/include/libcamera/internal/pipeline_handler.h +++ b/include/libcamera/internal/pipeline_handler.h @@ -89,6 +89,8 @@ public: const char *name() const { return name_; } + Size const &getSensorCrop() const { return sensorCrop_; } + protected: void registerCamera(std::shared_ptr camera, std::unique_ptr data); @@ -100,6 +102,8 @@ protected: CameraManager *manager_; + Size sensorCrop_; + private: void mediaDeviceDisconnected(MediaDevice *media); virtual void disconnect(); diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index 69a1b44..6614c93 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -793,6 +793,32 @@ int Camera::configure(CameraConfiguration *config) return 0; } +/** + * \brief Return the size of the sensor image being used to form the output + * + * This method returns the size, in pixels, of the raw image read from the + * sensor and which is used to form the output image(s). Note that these + * values take account of any cropping performed on the sensor output so + * as to produce the correct aspect ratio. It would normally be necessary + * to retrieve these values in order to calculate correct parameters for + * digital zoom. + * + * Example: a sensor mode may produce a 1920x1440 output image. But if an + * application has requested a 16:9 image, the values returned here would + * be 1920x1080 - the largest portion of the sensor output that provides + * the correct aspect ratio. + * + * \context This function is \threadsafe. It will only return valid + * (non-zero) values when the camera has been configured. + * + * \return The dimensions of the sensor image in use. + */ + +Size const &Camera::getSensorCrop() const +{ + return p_->pipe_->getSensorCrop(); +} + /** * \brief Create a request object for the camera * \param[in] cookie Opaque cookie for application use diff --git a/src/libcamera/control_ids.yaml b/src/libcamera/control_ids.yaml index 988b501..5a099d5 100644 --- a/src/libcamera/control_ids.yaml +++ b/src/libcamera/control_ids.yaml @@ -262,4 +262,14 @@ controls: In this respect, it is not necessarily aimed at providing a way to implement a focus algorithm by the application, rather an indication of how in-focus a frame is. + + - DigitalZoom: + type: Rectangle + description: | + Sets the portion of the full sensor image, in pixels, that will be + used for digital zoom. That is, this part of the sensor output will + be scaled up to make the full size output image (and everything else + discarded). To obtain the "full sensor image" that is available, the + method Camera::getOutputCrop() should be called once the camera is + configured. An application may pan and zoom within this rectangle. ...