From patchwork Wed Oct 11 14:02:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 19123 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 E24D1BD808 for ; Wed, 11 Oct 2023 14:02:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4B09D62973; Wed, 11 Oct 2023 16:02:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1697032971; bh=GomdPEPVrcNESzJyBxAoqZk6BGKR9BCN3FlxZeZKMWw=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=BXHH3nV4CtYpqsnARGL8P3MEpDkVVBA/ejZUmS3LPYTvP3rZEvnC83khTVMS7NqVL jhou0WCVaXc/21P1Ml7m8GUfWmw90hqFf0hreH+UH7CFj04yILCAa3PMzE3rLpC01k T+ub97/9ojI2cKPVk96BzaJXbwTm1kD+tt1g2guFg+wmwJ1bKh6hdVCwEuOKHMu2tn iBp6RsZ1PFmTGGL1D9xJxvH4vmA1Dm0N8NjFmgY+J4N/nWpGkmfFhMS98ywcNmD4kf bTcTcVxRXoG17CZWBGTDlOhwEOtqktei1XxXB3fzV+qZqZlIR8KkRkrDS/QUZNSXPj Xgp4XzaezRdhQ== Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3975262964 for ; Wed, 11 Oct 2023 16:02:49 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="MaTemkt9"; dkim-atps=neutral Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-317c3ac7339so6256949f8f.0 for ; Wed, 11 Oct 2023 07:02:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1697032968; x=1697637768; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=E+Jh1dA8fnY3rRZwJlxTJtxordOq8oPc4M6HR63GdkY=; b=MaTemkt9Ip9+0GEDt7VWydudWtuqN/6tdgY1h6Ch+1y42aE4F8RCGMIxF8ZdIQNbHO /6U92HL0C4U5ScDQ4XwaKRK7VJCB6jbQSN8ujQhVcFoFNLuAAn6hPaJS7WFm2R1PS1Vc fXynfaxEGwgyDLC2zfc2eUnQ0LEPxxl+XAFJBmdzSg+Oxai4Jwgty5Qu5XwKE9QE2ECC RROKqehVwiixojz4dfJPhcyJgtp72yTm908mG+iiS4MjzY5Si2BkXxm6n+WQcyvIuT4L cqzJUrjmmpFVHz274tqd9bEmj1FlVdGFQag0MXxsrYb4/HH1z/Nnfp0TqW10KSZ8d2/i DyAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697032968; x=1697637768; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=E+Jh1dA8fnY3rRZwJlxTJtxordOq8oPc4M6HR63GdkY=; b=mJCnfA+L7/0WSTbcJhnOvKuDJDwDqpElBoPr5tB7Kzxpb6ENFuqi3j0fHsh43XAbrP H7/B7gbGQEjRc7ouVE3zxu7oYz/Ie2WOnbgLjPXCYLQJ9hnak1cfBijsyzki/TEujS0Z ruhXfEjpoKsvHa866s3to5MeuLX7Hr8cJ23x9nNVUHyv+DWIIqJcHR5aTc09nMQyW//j MmmCQG4ZRJZlCFSWHNz5j+tDyUjxStEjfzEgBKAtBfEOQJPGT3+CcWviOZJbUNuXqtlF 8sB525oVoMtZV6zfpiKxvGQH9K+hJ9/hf5ytM3/o0zKJpamzb4x31Ow3Ri7PQY18GPtQ FkBA== X-Gm-Message-State: AOJu0YzVuO32CXMmPEUYQy3578Cp0NmIr41ZPB2kHVzrw9xbuRMXzdGx h9S6fhsBWqtumclBlqyQZS3YNYh3z7izUjo6VNE= X-Google-Smtp-Source: AGHT+IGrT1AV5g2bcbXMT8M+sRF8CEXCj1MOtd/MU/zKwszvB4/T3dTlMShl9S3gjDOyFZjXlLqFBw== X-Received: by 2002:a5d:4d8e:0:b0:324:7bdd:678e with SMTP id b14-20020a5d4d8e000000b003247bdd678emr17300141wru.60.1697032968413; Wed, 11 Oct 2023 07:02:48 -0700 (PDT) Received: from pi5-davidp.pitowers.org ([2a00:1098:3142:14:183e:6cc8:a436:a27c]) by smtp.gmail.com with ESMTPSA id o30-20020adfa11e000000b0031f3ad17b2csm2029347wro.52.2023.10.11.07.02.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 07:02:45 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 11 Oct 2023 15:02:38 +0100 Message-Id: <20231011140238.39058-1-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2] py: Add the SensorConfiguration class 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: David Plowman via libcamera-devel From: David Plowman Reply-To: David Plowman Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" We provide access to the various fields of the new SensorConfiguration class. The class also needs a constructor so that Python applications can make one and put it into the CameraConfiguration. Signed-off-by: David Plowman Reviewed-by: Kieran Bingham --- src/py/libcamera/py_main.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/py/libcamera/py_main.cpp b/src/py/libcamera/py_main.cpp index 01fb15a9..d2ce3722 100644 --- a/src/py/libcamera/py_main.cpp +++ b/src/py/libcamera/py_main.cpp @@ -112,6 +112,7 @@ PYBIND11_MODULE(_libcamera, m) auto pyCameraManager = py::class_>(m, "CameraManager"); auto pyCamera = py::class_>(m, "Camera"); + auto pySensorConfiguration = py::class_(m, "SensorConfiguration"); auto pyCameraConfiguration = py::class_(m, "CameraConfiguration"); auto pyCameraConfigurationStatus = py::enum_(pyCameraConfiguration, "Status"); auto pyStreamConfiguration = py::class_(m, "StreamConfiguration"); @@ -281,6 +282,40 @@ PYBIND11_MODULE(_libcamera, m) return ret; }); + pySensorConfiguration + .def(py::init<>()) + .def_readwrite("bit_depth", &SensorConfiguration::bitDepth) + .def_readwrite("analog_crop", &SensorConfiguration::analogCrop) + .def_property( + "binning", + [](SensorConfiguration &self) { + return py::make_tuple(self.binning.binX, self.binning.binY); + }, + [](SensorConfiguration &self, py::object value) { + auto vec = value.cast>(); + if (vec.size() != 2) + throw std::runtime_error("binning requires iterable of 2 values"); + self.binning.binX = vec[0]; + self.binning.binY = vec[1]; + }) + .def_property( + "skipping", + [](SensorConfiguration &self) { + return py::make_tuple(self.skipping.xOddInc, self.skipping.xEvenInc, + self.skipping.yOddInc, self.skipping.yEvenInc); + }, + [](SensorConfiguration &self, py::object value) { + auto vec = value.cast>(); + if (vec.size() != 4) + throw std::runtime_error("skipping requires iterable of 4 values"); + self.skipping.xOddInc = vec[0]; + self.skipping.xEvenInc = vec[1]; + self.skipping.yOddInc = vec[2]; + self.skipping.yEvenInc = vec[3]; + }) + .def_readwrite("output_size", &SensorConfiguration::outputSize) + .def("is_valid", &SensorConfiguration::isValid); + pyCameraConfiguration .def("__iter__", [](CameraConfiguration &self) { return py::make_iterator(self); @@ -293,6 +328,7 @@ PYBIND11_MODULE(_libcamera, m) py::return_value_policy::reference_internal) .def_property_readonly("size", &CameraConfiguration::size) .def_property_readonly("empty", &CameraConfiguration::empty) + .def_readwrite("sensor_config", &CameraConfiguration::sensorConfig) .def_readwrite("transform", &CameraConfiguration::transform); pyCameraConfigurationStatus