Patch Detail
Show a patch.
GET /api/patches/21424/?format=api
{ "id": 21424, "url": "https://patchwork.libcamera.org/api/patches/21424/?format=api", "web_url": "https://patchwork.libcamera.org/patch/21424/", "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": "<20240930084040.2919-3-naush@raspberrypi.com>", "date": "2024-09-30T08:40:40", "name": "[2/2] ipa: rpi: awb: Add a bias to the AWB search", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "0595786ceb2f2e7a3742515ab1e9b71ff82b5607", "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/21424/mbox/", "series": [ { "id": 4638, "url": "https://patchwork.libcamera.org/api/series/4638/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4638", "date": "2024-09-30T08:40:38", "name": "RPi: AWB bias", "version": 1, "mbox": "https://patchwork.libcamera.org/series/4638/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/21424/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/21424/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 5EF7CC0F1B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 30 Sep 2024 08:40:41 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EE66D6351A;\n\tMon, 30 Sep 2024 10:40:38 +0200 (CEST)", "from mail-wr1-x435.google.com (mail-wr1-x435.google.com\n\t[IPv6:2a00:1450:4864:20::435])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 57BC06350F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 30 Sep 2024 10:40:31 +0200 (CEST)", "by mail-wr1-x435.google.com with SMTP id\n\tffacd0b85a97d-37cde5c2700so81600f8f.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 30 Sep 2024 01:40:31 -0700 (PDT)", "from naush-laptop.pitowers.org ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tffacd0b85a97d-37cd57423afsm8463421f8f.90.2024.09.30.01.40.29\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 30 Sep 2024 01:40:29 -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=\"XB+MR8Ed\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1727685631; x=1728290431;\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=eyOiGQZUubNluqCplMlAYaj328dUjPUH55z+f5YjsEQ=;\n\tb=XB+MR8Ed3Xcz6t6zLg7RCW0HKKQblNbul7RCWZmYqZhwWiwY8rzQsTfy5Z2j4z6nlc\n\tzx4+RIkFfdZlYQyLfF+pcX3ssMLq3J/mpz6LeZE6TWOjGS2stEuXcm8F9DbWsBb060hs\n\tGtKUTNkDRA3FxVnO2Tn2MQRHz/XtcLfP4Zl21z7ICnHbHqm2aucUSROAM6cGU1/KK/CB\n\tt3cp3/1BaupoOyt5oBBub9h0ZkmPzKVYHQIB1wDXVr+bcoF4nqF3yZ2ROLc6TCBdUwUq\n\tlPv6gm7ahA3bpZT7WcphZSoXrHPbJrCujpXDuASk63pBtsFbtNklU3SpuLXyyFTvdiKL\n\tzFkA==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1727685631; x=1728290431;\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=eyOiGQZUubNluqCplMlAYaj328dUjPUH55z+f5YjsEQ=;\n\tb=BxIH5qbQpMoHUnY/7QOFYAHCsJUxswD3ej9fmjqNnaSFze5C+IfFe/suKeyMEpYcKF\n\tkYUL/lryh6QtmtWfG6RPLcBRLNXCdb8pdAubqDFVqxi3gVAB5uNAXO8wx0/LnkGiyoxz\n\tQrppJLiPNI+OAteELlo12nDDuJBJW/ZZHGBETudhuVs8jmZ7IBezeyPOOFzPW3qIU106\n\tX0GqDVgnA7GWVHP1luFxBYUyhPuQCLWOqO2LspBPcvdP4gLS0n6bBJ1HqcVQRNFE84jJ\n\tYODeIFYn+2TpmiSlC6WQvxTYnHwdYSL1cEhUdMrd+gUnQ2Jykb6w5+owHKMfuuAXcfgE\n\thUPg==", "X-Gm-Message-State": "AOJu0YzRBZ34nCUCJSED6H/Bv65O60rnRQnTYxo6l7K6xmKO2NcYfJjj\n\tej7fp706DlqEtjrOMpnxt2x8OEouz5fMulFrnMMoqGwqPFaplUZ2BaQMp88GJYsc1isaCX3mMne\n\tj", "X-Google-Smtp-Source": "AGHT+IEIoI98WwIOR0gNaqH/3H3T+mWuWaocuN0QxHdgVRBmAzemBLgDjSQbbSnk7VK+aIr7iKlbQQ==", "X-Received": "by 2002:a05:6000:1fab:b0:375:bb30:6525 with SMTP id\n\tffacd0b85a97d-37cd5a616edmr3090003f8f.1.1727685630515; \n\tMon, 30 Sep 2024 01:40:30 -0700 (PDT)", "From": "Naushir Patuck <naush@raspberrypi.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Naushir Patuck <naush@raspberrypi.com>", "Subject": "[PATCH 2/2] ipa: rpi: awb: Add a bias to the AWB search", "Date": "Mon, 30 Sep 2024 09:40:40 +0100", "Message-Id": "<20240930084040.2919-3-naush@raspberrypi.com>", "X-Mailer": "git-send-email 2.34.1", "In-Reply-To": "<20240930084040.2919-1-naush@raspberrypi.com>", "References": "<20240930084040.2919-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>\n---\n src/ipa/rpi/controller/rpi/awb.cpp | 17 +++++++++++++++--\n src/ipa/rpi/controller/rpi/awb.h | 4 ++++\n 2 files changed, 19 insertions(+), 2 deletions(-)", "diff": "diff --git a/src/ipa/rpi/controller/rpi/awb.cpp b/src/ipa/rpi/controller/rpi/awb.cpp\nindex 24f296fc66fa..8f46dae0a961 100644\n--- a/src/ipa/rpi/controller/rpi/awb.cpp\n+++ b/src/ipa/rpi/controller/rpi/awb.cpp\n@@ -169,6 +169,8 @@ 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+\tbiasProportion = params[\"bias_proportion\"].get<double>(0.0);\n+\tbiasCT = params[\"bias_ct\"].get<double>(DefaultCT);\n \treturn 0;\n }\n \n@@ -409,7 +411,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@@ -422,6 +425,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@@ -442,7 +453,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": [ "2/2" ] }