From patchwork Thu May 5 10:41:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 15795 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 500DBC326C for ; Thu, 5 May 2022 10:41:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 041066563F; Thu, 5 May 2022 12:41:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1651747299; bh=7ewMQMZf89XHV6ZaBIDyoZUBi1MJitfvIQ3YDvgenug=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=I3W911YCnBSHtIokLsXBiVNRQAC0GVk0ogtaCCqAI/9M7RpwTHp4klXKLGJ+/WCrU Sj/FtENsHEBm9RCk71wAmUd/sx2DUgm698R/rAKt1eycsd9wQePS2Zymgx0j3u4yul RjJxVJMXWPSWzT1PA9Gk2ePkN6KBcoNYSKqrtcUSAGolssnldeFEyC4oK9V7mRfvKv 2VPZIJF5KEIoR2VoMEAqtfQPKOC/hd4A8YWekixF32yMPrt1MpM5ZpQ8/+hLEov8eY rhuZ9R4qfvgIn+fm/WdsbTtDo1fCYyjOb/EZmMJMmBLCrTvtKYyIPHWqVZ1xfShQXi 2S5sZcIeKEUYQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1344865645 for ; Thu, 5 May 2022 12:41:32 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="qvqHBVQM"; dkim-atps=neutral Received: from deskari.lan (91-156-85-209.elisa-laajakaista.fi [91.156.85.209]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 80B49D9D; Thu, 5 May 2022 12:41:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1651747291; bh=7ewMQMZf89XHV6ZaBIDyoZUBi1MJitfvIQ3YDvgenug=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qvqHBVQMiVC+VrfVFRCdyiLGGdh6a9Q5+B5X7b1fMGhs44W+G9B9i8GPNDPWnTVJ4 YmPlM5IPBFsbPGR7ooT2LVCZjmMQOZYuz/tn8u2P2IW/0sK+/12+h3boFyTiWN8A6C ZneTvPjKn/LUxH/iWUUMgqt9zvPyxuBqzluJOYXE= To: libcamera-devel@lists.libcamera.org, David Plowman , Kieran Bingham , Laurent Pinchart , Jacopo Mondi Date: Thu, 5 May 2022 13:41:03 +0300 Message-Id: <20220505104104.70841-13-tomi.valkeinen@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220505104104.70841-1-tomi.valkeinen@ideasonboard.com> References: <20220505104104.70841-1-tomi.valkeinen@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v7 12/13] py: add support for setting Rectangle and Size controls 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: , X-Patchwork-Original-From: Tomi Valkeinen via libcamera-devel From: Tomi Valkeinen Reply-To: Tomi Valkeinen Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: David Plowman Allows, for example, ScalerCrop to be controlled for digital zoom. Signed-off-by: David Plowman Signed-off-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart --- src/py/libcamera/pymain.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/py/libcamera/pymain.cpp b/src/py/libcamera/pymain.cpp index 6375e326..b9b52f6b 100644 --- a/src/py/libcamera/pymain.cpp +++ b/src/py/libcamera/pymain.cpp @@ -101,8 +101,14 @@ static ControlValue PyToControlValue(const py::object &ob, ControlType type) return ControlValueMaybeArray(ob); case ControlTypeString: return ControlValue(ob.cast()); - case ControlTypeRectangle: - case ControlTypeSize: + case ControlTypeRectangle: { + auto array = ob.cast>(); + return ControlValue(Rectangle(array[0], array[1], array[2], array[3])); + } + case ControlTypeSize: { + auto array = ob.cast>(); + return ControlValue(Size(array[0], array[1])); + } case ControlTypeNone: default: throw runtime_error("Control type not implemented");