From patchwork Thu Oct 23 11:49:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 24726 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 C213CC32CE for ; Thu, 23 Oct 2025 11:50:44 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AE18960763; Thu, 23 Oct 2025 13:50:42 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="L2VxCyfj"; dkim-atps=neutral Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9F708606E0 for ; Thu, 23 Oct 2025 13:50:40 +0200 (CEST) Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-4270a0127e1so476435f8f.3 for ; Thu, 23 Oct 2025 04:50:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1761220240; x=1761825040; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PSNl1fKNYqqrXL9+8+lTPsK2c3rNasItZ3vGAP/DQ3Q=; b=L2VxCyfjCa9x+W9X8kOXsI1mWQTTbYtvmk3+shC/vCV2Pp5x6JJBiuAdJ5dUVTinTQ 02Ua/k06WLIxdy9TvFrOW2aaaZFPPNeZufjwnmJHkHlT7BURMcAWJQycMnQdXxIQwiaP E2EmlSIVg1xuEdttM0reZYvXb2cCevxvwPTcu08eezmHXIXb8BaJ8DJaEePAev9+xZgi TIBnO9x0bo7nNEfntF+lQlMLJjV1rvLJvHX4zpQRwAysab4Z15rNn+9mc5RWKBbRKcwL zk4QqecGP1faFet1t9Ad+DnD4MThu6cpKRrXOK/Myh8v1gd4RiBvFMpXRp9xw5+i61sA xslw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761220240; x=1761825040; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PSNl1fKNYqqrXL9+8+lTPsK2c3rNasItZ3vGAP/DQ3Q=; b=pDriTIV/E9hOV+GlCgtV3KuegblllczJclKOdpt6ieThgLUUkD4psuHcGPDYi4vAL5 OIxNoR2uMApYI6FtCqGxc4btVNEbhgfGUAfUhB7Jkmn0VXM+SDVAhGh5yvc+u53F9HF5 HP1cnH1Lby1NxT4wbbkIcO0RSAvIszCwg/PrmYm4GZnEIUjNLlbJjv0UcaiKc1Bdcs6O tli7PEkKcxO3jaDZfjSRG59255gAgZINKugXTwbU50KUj1FEHC3EeU9PxM+FC6+Zlf3I KNcMMwiVc3yNRgJ830ZuOi6ZoOmgP7/JRIefDNbK7QHFGLVn3RloiJ8ewyzneW56uADC qfLA== X-Gm-Message-State: AOJu0YwTU9158QKwJ52k/Yj4zwIYrrO/5Ax8kzomJ2lHzq3KYrhi7bTW dIGQ8X8JXth3cupAghSuTQ0rey/GC0mJzqdMsvytRofwzvCpj8y9eAlu5q20vYKO9nrsZ9Ypslr uPGQHvSA= X-Gm-Gg: ASbGncubCzowtAYSYAOFjoXoXtGMX6CBYmnKcBpM8zfg1ijsdmWay87LxDSGABZ+/7a AMo+zr9DTt2alzLzOnpyuIeOFKaJetqFjyLc+vlTxkZlo93lJC9W7pkqOS/BT0l+XwbaUu2SHeh 81meA4yCVzkHMAEGD4aXtIfV1Pi+jzcyLbgLKo4Zu9NjRy+xsfDoH5H/3rRl0sGSUEvgJuYmFLJ XUQhhyu5CEJYLEOunj8cX84isFpSNdgn8ZAI0x3+reIiPgfzssdAAcL3D/qDb2ZmKWcsejH1Vmu oc/B4JphjevGLwqTULn+Zld67JTQEmkS3f8Mb8cr5r18k/3gSa5IG/Rw4xBeKhFG9fS0074qtNN GCsuO4v6WqE5rDAW0iCRw9AXox7v/yIac22YULE22LJj0Uk5/nlEBifUOIAP1j2r/6Nn9jt6JiV 2RDX8NylAOiseN+/RkTPPwur3YDzt3ftjQmrYtyc9yCEX/g2YNg1FC8QB3a74uaefJzHwhx0eu2 uBiEEIGK6VC5+AidUlxir7s8Hnl X-Google-Smtp-Source: AGHT+IGbhRN+qq3Z9z6JiQW0ZVh8wg7+9uOnfl74KhmEkABF5sdfWdNBSEp9ZMlNcFK25UnndBzsRQ== X-Received: by 2002:a05:6000:612:b0:3fe:efa8:7f1d with SMTP id ffacd0b85a97d-42704d4431cmr14886080f8f.7.1761220239833; Thu, 23 Oct 2025 04:50:39 -0700 (PDT) Received: from davidp-pi.pitowers.org ([2a00:1098:3142:1f:f75f:a9a5:3eb7:34d4]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4298b996aaasm1900760f8f.3.2025.10.23.04.50.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Oct 2025 04:50:39 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Cc: David Plowman , Stefan Klug , Naushir Patuck Subject: [PATCH v2 1/5] ipa: rpi: Fix the set function for floating statistics regions Date: Thu, 23 Oct 2025 12:49:13 +0100 Message-ID: <20251023115034.2207-2-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251023115034.2207-1-david.plowman@raspberrypi.com> References: <20251023115034.2207-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 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" Previously it was calling the wrong internal function which would do nothing. Signed-off-by: David Plowman Reviewed-by: Stefan Klug Reviewed-by: Naushir Patuck --- src/ipa/rpi/controller/region_stats.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ipa/rpi/controller/region_stats.h b/src/ipa/rpi/controller/region_stats.h index c60f7d9a..0f8c276a 100644 --- a/src/ipa/rpi/controller/region_stats.h +++ b/src/ipa/rpi/controller/region_stats.h @@ -76,7 +76,7 @@ public: { if (index >= numFloatingRegions()) return; - set(numRegions() + index, region); + set_(numRegions() + index, region); } const Region &get(unsigned int index) const From patchwork Thu Oct 23 11:49:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 24727 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 71B63C3331 for ; Thu, 23 Oct 2025 11:50:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6BC6A607E5; Thu, 23 Oct 2025 13:50:45 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="Iq+MKu92"; dkim-atps=neutral Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1691A607CA for ; Thu, 23 Oct 2025 13:50:41 +0200 (CEST) Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-4270a3464bcso557403f8f.2 for ; Thu, 23 Oct 2025 04:50:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1761220241; x=1761825041; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SVMDCIFmjD7WxzZUSX69iF9RZaDZQ5KpDvQNG78nIu8=; b=Iq+MKu92uISuNesYSDo06xiSn1BJGhMamOWNErTSXh0duAD2mKgFU63Ydd/pSYhExp NSporsK5hdb0F7c1ummC6GeWKionBG2U4ahSIX91lsuE+/WsW6nAwyNGnLkXf6iSm/ZZ vbNzntOwBIlkz48QqSgBTuuJ6MaQGKCH17jutQZyRjHUojHwFxlaEUpDnnpqaLK9IlKk P1QtZYxhXhNAug3W7NN3LFfwZSW2nW2fZpW3pjtST/ZCxCxjE4DHwxUFngkEMiZON7OU akm8PPYeamxXJcUraMxTC7CV0w6o7bniOuCKfAjmKMoerQ3nz+qYrgcVjnRH2wB5pRXJ /aAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761220241; x=1761825041; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SVMDCIFmjD7WxzZUSX69iF9RZaDZQ5KpDvQNG78nIu8=; b=Pe1uroAcZFSv2nljSRno3yrjQk0r+024DgQl+3SHUeAQMr78fokrEw/EQQ9JW1vabL S41grTSUJdqhr3+o/yNo6VZ4sAvH7pG3encvG7pPxw1R83lk7OTFTHnlMYzY3/w3qWKF s8Tc04GdNVp2yyxXhMa9jkR9hEXTalrRbkflVy4AY7WHuL5m51Gn7cVhJyNRzB9fymzq D/myCDkHQ2bbhPj2bWjhjUbTCX+aE3pEq7tapk/uLBnURC5Uq+pNMyHTqwkXMF691RLH g189swVEkp8ZduDTU+X6/P85IkogWqMChnBBwDxK6lg576BAReW33ZBYDjL+LMrH95Y2 Og0w== X-Gm-Message-State: AOJu0YxTmfUbT1qyUCvVY9CFI6xzxfYoHtxsvbOllW/cBy9YXqn+zzbK /4SUAg6/198C8dbWvThaV+p9H5FIiIxHGpb1goTPZGLVIR/1Zyb2RWMyShKEW1pKYeJWxcXKnID Cjr8i0ZM= X-Gm-Gg: ASbGnct69EXG2JK6W9Q+nKoS5HccA/OhY1gYGwVEIvpwUzZfj+oxqabxmw7Lc0eWrZd BnZwwt6mW0rOANBCM52fD03X5ygUq2hzuPn4+bZxkHtlnNwK1FQL55EFQ998SbqeJ6Nqd4iMYbc GF93Atr0NL8MYEvF1uX2HUn476LuLTh6wRnh0/YEJhXVbY80ZEtd+aDLUIoXUa18XKkygG/KtGt gbIarJJcRrQNl41tz8pHyzyKGJSd1zuR1w65pCNuwHs64ciic1jdNa9l2VkgWeEJZTG27ilwtdO M97AufWunWw54WU+WRkT6MBS+fF4OI6fsizl/AKYoaDA/bwrVphnaiTftwPKyuZvt1i1uIWl9oQ rT3SjX+DbCxc/ktWMXShXFrlnt9HFTE9+HKGpSqX6CAdJ/zYy3q5SEXUsQkZs1RCDV4UjqwWtDs UDOx10hHWnrXI+Zj8Gbk78IBQnQ4i0APVg5+E/CniZf/Lf8TugV8dWiIp1sy+hGQv+ja2C2psEV N0qPxrix7ZPU8pa+A== X-Google-Smtp-Source: AGHT+IEh2jDPJUwmqChoV8H5GQ51WNy79xQP2n67V5xeX0gJtKHGRFEtZKkUiBhEKaMYC1ZwNlNlNQ== X-Received: by 2002:a5d:5f82:0:b0:3eb:5245:7c1f with SMTP id ffacd0b85a97d-42704d7ea04mr13991409f8f.2.1761220240957; Thu, 23 Oct 2025 04:50:40 -0700 (PDT) Received: from davidp-pi.pitowers.org ([2a00:1098:3142:1f:f75f:a9a5:3eb7:34d4]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4298b996aaasm1900760f8f.3.2025.10.23.04.50.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Oct 2025 04:50:40 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Cc: David Plowman , Stefan Klug , Naushir Patuck Subject: [PATCH v2 2/5] ipa: rpi: lux: Handle camera mode sensitivity correctly Date: Thu, 23 Oct 2025 12:49:14 +0100 Message-ID: <20251023115034.2207-3-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251023115034.2207-1-david.plowman@raspberrypi.com> References: <20251023115034.2207-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 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" The camera mode sensitivity needs to be taken into account for the lux calculation. For example, the IMX708 binned mode (with a sensitivity of 2.0) would otherwise show double the correct lux value. Signed-off-by: David Plowman Reviewed-by: Stefan Klug Reviewed-by: Naushir Patuck --- src/ipa/rpi/controller/rpi/lux.cpp | 13 +++++++++++-- src/ipa/rpi/controller/rpi/lux.h | 3 +++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/ipa/rpi/controller/rpi/lux.cpp b/src/ipa/rpi/controller/rpi/lux.cpp index 27b89a8f..acaa6e57 100644 --- a/src/ipa/rpi/controller/rpi/lux.cpp +++ b/src/ipa/rpi/controller/rpi/lux.cpp @@ -20,7 +20,7 @@ LOG_DEFINE_CATEGORY(RPiLux) #define NAME "rpi.lux" Lux::Lux(Controller *controller) - : Algorithm(controller) + : Algorithm(controller), sensitivity_(1.0) { /* * Put in some defaults as there will be no meaningful values until @@ -68,6 +68,13 @@ void Lux::setCurrentAperture(double aperture) currentAperture_ = aperture; } +void Lux::switchMode(CameraMode const &cameraMode, [[maybe_unused]] Metadata *metadata) +{ + /* We will need to compensate for the camera sensitivity. */ + ASSERT(cameraMode.sensitivity); + sensitivity_ = cameraMode.sensitivity; +} + void Lux::prepare(Metadata *imageMetadata) { std::unique_lock lock(mutex_); @@ -88,10 +95,12 @@ void Lux::process(StatisticsPtr &stats, Metadata *imageMetadata) double yRatio = currentY * (65536 / stats->yHist.bins()) / referenceY_; double estimatedLux = exposureTimeRatio * gainRatio * apertureRatio * apertureRatio * - yRatio * referenceLux_; + yRatio * referenceLux_ / sensitivity_; + LuxStatus status; status.lux = estimatedLux; status.aperture = currentAperture; + LOG(RPiLux, Debug) << ": estimated lux " << estimatedLux; { std::unique_lock lock(mutex_); diff --git a/src/ipa/rpi/controller/rpi/lux.h b/src/ipa/rpi/controller/rpi/lux.h index da007fe9..db2227e4 100644 --- a/src/ipa/rpi/controller/rpi/lux.h +++ b/src/ipa/rpi/controller/rpi/lux.h @@ -10,6 +10,7 @@ #include +#include "../camera_mode.h" #include "../lux_status.h" #include "../algorithm.h" @@ -23,6 +24,7 @@ public: Lux(Controller *controller); char const *name() const override; int read(const libcamera::YamlObject ¶ms) override; + void switchMode(CameraMode const &cameraMode, Metadata *metadata) override; void prepare(Metadata *imageMetadata) override; void process(StatisticsPtr &stats, Metadata *imageMetadata) override; void setCurrentAperture(double aperture); @@ -40,6 +42,7 @@ private: double currentAperture_; LuxStatus status_; std::mutex mutex_; + double sensitivity_; }; } /* namespace RPiController */