Patch Detail
Show a patch.
GET /api/patches/21533/?format=api
{ "id": 21533, "url": "https://patchwork.libcamera.org/api/patches/21533/?format=api", "web_url": "https://patchwork.libcamera.org/patch/21533/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20241008081317.24602-2-naush@raspberrypi.com>", "date": "2024-10-08T08:13:17", "name": "[v3,2/2] ipa: rpi: awb: Add a bias to the AWB search", "commit_ref": "ea8fd63d936f19bfc773199b9fe81e8d5d1f709b", "pull_url": null, "state": "accepted", "archived": false, "hash": "e7a50165c78f0d6a441b6217834318f03804e21f", "submitter": { "id": 34, "url": "https://patchwork.libcamera.org/api/people/34/?format=api", "name": "Naushir Patuck", "email": "naush@raspberrypi.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/21533/mbox/", "series": [ { "id": 4663, "url": "https://patchwork.libcamera.org/api/series/4663/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4663", "date": "2024-10-08T08:13:16", "name": "[v3,1/2] ipa: rpi: awb: Add a const for the default colour temperature", "version": 3, "mbox": "https://patchwork.libcamera.org/series/4663/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/21533/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/21533/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 C3A57BD80A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 8 Oct 2024 08:13:34 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2DDA46353A;\n\tTue, 8 Oct 2024 10:13:32 +0200 (CEST)", "from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com\n\t[IPv6:2a00:1450:4864:20::32b])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id ADA6463537\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 8 Oct 2024 10:13:28 +0200 (CEST)", "by mail-wm1-x32b.google.com with SMTP id\n\t5b1f17b1804b1-42e6dbc8c7dso8783345e9.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 08 Oct 2024 01:13:28 -0700 (PDT)", "from naush-laptop.pitowers.org ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tffacd0b85a97d-37d1695e62bsm7492587f8f.81.2024.10.08.01.13.27\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 08 Oct 2024 01:13:27 -0700 (PDT)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"swTBWijK\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1728375208; x=1728980008;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=I7AR8ICqltR9rP3dW1XPHYWeiKNlWZkRhiTUDjh6+Z0=;\n\tb=swTBWijKyYWFr5H2KUTX4PbQx5Fe/eGqiUODMBgj06KugFN9je5KQjtbl5paIJmNuu\n\t7NPAXqIiAdvctU3Byy7/elAm705Cbl+IkCkLdZ7Ho4jfCce+OHOgwvkB0u0x6hfvZWlI\n\topLg7zpsIXkqcGpGSleCtxK6UZpGyWtRHByYCoaQ+HeEtjyjqiU41B1f25omlgctN/b/\n\teQ8NupnN53LRCqurv1E4sAk5AxnK+mgObhEcSnU8cl05WFSZPMik0bakH8P1/kCOMklD\n\tDIb8UfsvPRFB9aook/VbgmjOucjsbIazDezTTgGipAhCQhSSzRDlRsZZ6Rlg/QPYEitO\n\tUwTg==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1728375208; x=1728980008;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=I7AR8ICqltR9rP3dW1XPHYWeiKNlWZkRhiTUDjh6+Z0=;\n\tb=CXKi6/zQXRWRZj6BiyV+eJw8Th7yl67l/izmfQ5SSJ2XxoCcRmDM22WoW29qTQZm37\n\tI3KP/fh3GHf+9/jn4jmltdh2zBPU4T3w4VL4urnOgzU4xuiWFUZyA+nYnQihCgbuSzXC\n\tZhSwcD62mfWQrLvn+fRYMwaWOJaU1dwgttcbtNIlR3lyRbVDwOXnf3VuGhfxxwWGVRO7\n\tDYHK3vur5FqlFnDXx4JDv6ETlQz+bkeZFJJUMtH6i1xBZCnANL1d+wOg6OahiQk3JR2f\n\t7LUtLuwMYYJbfTGT3feOb2TSCcDfmQHZfVcFkwEIMsEEs9FauX2KlTeNnyFA5F+qEf2m\n\tAGNw==", "X-Gm-Message-State": "AOJu0YzqYN23LB7ZVgrbMjAl88qMVoPegCLGOLohCflNN4IRBN5yue9d\n\tcRovEeXCXAbhv7HGK4V3siNhnUHj2Jo19/my8136Tw7GD3zVylSBORzXfN1OX3PYXx2QuClbYqc\n\tn", "X-Google-Smtp-Source": "AGHT+IEBGTY7H3EwirD41jf8M+t2LuwQ0w2FAewn+Ciy3NGMBh5awZijX607HLcAqYY/Vv56C+IAtA==", "X-Received": "by 2002:a05:600c:1390:b0:42c:bb35:b6d0 with SMTP id\n\t5b1f17b1804b1-42f85aa361cmr48594995e9.1.1728375207946; \n\tTue, 08 Oct 2024 01:13:27 -0700 (PDT)", "From": "Naushir Patuck <naush@raspberrypi.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Naushir Patuck <naush@raspberrypi.com>,\n\tDavid Plowman <david.plowman@raspberrypi.com>", "Subject": "[PATCH v3 2/2] ipa: rpi: awb: Add a bias to the AWB search", "Date": "Tue, 8 Oct 2024 09:13:17 +0100", "Message-Id": "<20241008081317.24602-2-naush@raspberrypi.com>", "X-Mailer": "git-send-email 2.34.1", "In-Reply-To": "<20241008081317.24602-1-naush@raspberrypi.com>", "References": "<20241008081317.24602-1-naush@raspberrypi.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "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>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "In the case of an AWB search failure, the current algorithm logic will\nreturn a point on the CT curve closest to where the search finisned.\nThis can be quite undesirable. Instead, add some bias params to the AWB\nalgorithm which will direct the search to a set CT value in the case\nwhere statistics become unreliable causing the search to fail.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\n---\n src/ipa/rpi/controller/rpi/awb.cpp | 23 +++++++++++++++++++++--\n src/ipa/rpi/controller/rpi/awb.h | 4 ++++\n 2 files changed, 25 insertions(+), 2 deletions(-)", "diff": "diff --git a/src/ipa/rpi/controller/rpi/awb.cpp b/src/ipa/rpi/controller/rpi/awb.cpp\nindex 65416d05b28e..9d8e170d1bfe 100644\n--- a/src/ipa/rpi/controller/rpi/awb.cpp\n+++ b/src/ipa/rpi/controller/rpi/awb.cpp\n@@ -170,6 +170,14 @@ int AwbConfig::read(const libcamera::YamlObject ¶ms)\n \twhitepointB = params[\"whitepoint_b\"].get<double>(0.0);\n \tif (bayes == false)\n \t\tsensitivityR = sensitivityB = 1.0; /* nor do sensitivities make any sense */\n+\t/*\n+\t * The biasProportion parameter adds a small proportion of the counted\n+\t * pixles to a region biased to the biasCT colour temperature.\n+\t *\n+\t * A typical value for biasProportion would be between 0.05 to 0.1.\n+\t */\n+\tbiasProportion = params[\"bias_proportion\"].get<double>(0.0);\n+\tbiasCT = params[\"bias_ct\"].get<double>(kDefaultCT);\n \treturn 0;\n }\n \n@@ -410,7 +418,8 @@ void Awb::asyncFunc()\n \n static void generateStats(std::vector<Awb::RGB> &zones,\n \t\t\t StatisticsPtr &stats, double minPixels,\n-\t\t\t double minG, Metadata &globalMetadata)\n+\t\t\t double minG, Metadata &globalMetadata,\n+\t\t\t double biasProportion, double biasCtR, double biasCtB)\n {\n \tstd::scoped_lock<RPiController::Metadata> l(globalMetadata);\n \n@@ -423,6 +432,14 @@ static void generateStats(std::vector<Awb::RGB> &zones,\n \t\t\t\tcontinue;\n \t\t\tzone.R = region.val.rSum / region.counted;\n \t\t\tzone.B = region.val.bSum / region.counted;\n+\t\t\t/*\n+\t\t\t * Add some bias samples to allow the search to tend to a\n+\t\t\t * bias CT in failure cases.\n+\t\t\t */\n+\t\t\tconst unsigned int proportion = biasProportion * region.counted;\n+\t\t\tzone.R += proportion * biasCtR;\n+\t\t\tzone.B += proportion * biasCtB;\n+\t\t\tzone.G += proportion * 1.0;\n \t\t\t/* Factor in the ALSC applied colour shading correction if required. */\n \t\t\tconst AlscStatus *alscStatus = globalMetadata.getLocked<AlscStatus>(\"alsc.status\");\n \t\t\tif (stats->colourStatsPos == Statistics::ColourStatsPos::PreLsc && alscStatus) {\n@@ -443,7 +460,9 @@ void Awb::prepareStats()\n \t * any LSC compensation. We also ignore config_.fast in this version.\n \t */\n \tgenerateStats(zones_, statistics_, config_.minPixels,\n-\t\t config_.minG, getGlobalMetadata());\n+\t\t config_.minG, getGlobalMetadata(),\n+\t\t config_.biasProportion, config_.ctR.eval(config_.biasCT),\n+\t\t config_.ctB.eval(config_.biasCT));\n \t/*\n \t * apply sensitivities, so values appear to come from our \"canonical\"\n \t * sensor.\ndiff --git a/src/ipa/rpi/controller/rpi/awb.h b/src/ipa/rpi/controller/rpi/awb.h\nindex ab30f4fa51c1..5d628b47c8a6 100644\n--- a/src/ipa/rpi/controller/rpi/awb.h\n+++ b/src/ipa/rpi/controller/rpi/awb.h\n@@ -87,6 +87,10 @@ struct AwbConfig {\n \tdouble whitepointR;\n \tdouble whitepointB;\n \tbool bayes; /* use Bayesian algorithm */\n+\t/* proportion of counted samples to add for the search bias */\n+\tdouble biasProportion;\n+\t/* CT target for the search bias */\n+\tdouble biasCT;\n };\n \n class Awb : public AwbAlgorithm\n", "prefixes": [ "v3", "2/2" ] }