Patch Detail
Show a patch.
GET /api/1.1/patches/17701/?format=api
{ "id": 17701, "url": "https://patchwork.libcamera.org/api/1.1/patches/17701/?format=api", "web_url": "https://patchwork.libcamera.org/patch/17701/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/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": "<20221027113956.7854-1-david.plowman@raspberrypi.com>", "date": "2022-10-27T11:39:56", "name": "[libcamera-devel] ipa: raspberrypi: awb: Update colour temperature whenever manual gains change", "commit_ref": "375a70d43eaa30e0c4f59f3da209a0f9fdf2b889", "pull_url": null, "state": "accepted", "archived": false, "hash": "3a6d979fb41c7c81be0d8aa1a4d862cff8725c6b", "submitter": { "id": 42, "url": "https://patchwork.libcamera.org/api/1.1/people/42/?format=api", "name": "David Plowman", "email": "david.plowman@raspberrypi.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/17701/mbox/", "series": [ { "id": 3580, "url": "https://patchwork.libcamera.org/api/1.1/series/3580/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3580", "date": "2022-10-27T11:39:56", "name": "[libcamera-devel] ipa: raspberrypi: awb: Update colour temperature whenever manual gains change", "version": 1, "mbox": "https://patchwork.libcamera.org/series/3580/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/17701/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/17701/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 74D38BD16B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 27 Oct 2022 11:40:10 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D955A62F87;\n\tThu, 27 Oct 2022 13:40:09 +0200 (CEST)", "from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com\n\t[IPv6:2a00:1450:4864:20::42b])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A36C962F0C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 27 Oct 2022 13:40:08 +0200 (CEST)", "by mail-wr1-x42b.google.com with SMTP id a14so1698070wru.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 27 Oct 2022 04:40:08 -0700 (PDT)", "from pi4-davidp.pitowers.org\n\t([2a00:1098:3142:14:e4a2:3070:eea4:e434])\n\tby smtp.gmail.com with ESMTPSA id\n\tg23-20020a7bc4d7000000b003b3307fb98fsm1253529wmk.24.2022.10.27.04.40.07\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 27 Oct 2022 04:40:07 -0700 (PDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1666870809;\n\tbh=7DtEcKB6Y/vYDPtigNOGHOhe5G1W2wRl8cLenLRqCe0=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=4QbdXtQ6zOSLQquGau0O3ZFKABDr7pFt/MByuYw0Ph8/pzXPFD854bC5zJzAuKOWs\n\tF9T33GjnrRpFUDvVxhYVBoZSVfin4pkEyrZLfiU7+wAv68wUi6VU0+Tbv1g+hFiUfP\n\t/Z0ZcIZv7a/FW+ub1LaURwnk5q9Cy/2qLUPCnDTtUjjo+5GLiIKHuBUDuEA9NOyiqB\n\t1ZyuQ0HccYRcJc7jen8gZ5ORHEYSQHx7ykECMhaXEb7w3+EkvssrNCi0B6UYStQJNO\n\ts7xtJ6qEgNTCoQNIzzUabZBc2SyyhYsEi8ZYlEICp3wNmzE9pShn85lAn83R9MAAuF\n\t1rLC4miL7JU/w==", "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=content-transfer-encoding:mime-version:message-id:date:subject:cc\n\t:to:from:from:to:cc:subject:date:message-id:reply-to;\n\tbh=+Ulk/1RYgIvbf97P4QQS65Z/beEG23xHntTXv82ASJw=;\n\tb=U86QPiKZxm5QeYhsXqrS4GFLkBwWD3s2xswmHy61b8iYY/LlWrA5kEflexSsryMtKx\n\t4lnvaWYPJm5sGD0jeXujcEs0DLtLzgAlPRuStqvstbIwsytO73x2EHaYL0LzTb9ArSlg\n\tXLxF2naublomU/Trynhe5T3iNeQB++/cPMdZjfLCxDyWeIvXe8WVu/25MRgAWQ58aThY\n\tf7NuHRB4z5UvUzQsXe3BsC8Np/EG7L8b3XrxfhyyNhulJf7879PLUp4iCZWX77XPZGcQ\n\tjwn56/Sh/J+OK/YxUpCmMGjsL50+nw5m10Chkc9UbS/akLf3MqRuhKpGVGximpZxY/4Y\n\tcvew==" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"U86QPiKZ\"; dkim-atps=neutral", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=content-transfer-encoding:mime-version:message-id:date:subject:cc\n\t:to:from:x-gm-message-state:from:to:cc:subject:date:message-id\n\t:reply-to;\n\tbh=+Ulk/1RYgIvbf97P4QQS65Z/beEG23xHntTXv82ASJw=;\n\tb=28w7N+KmSM5n6Jg/7N8+Q83ADKU+5oxgCRDUOscTALdn3vUtJS8UsiWuMkQoZ9H+mf\n\tiKvQcZQownp8wlDqS2IY/tNuZDklbH4W4j6CmqfBc/tOroHJumuH/jakgRSCu6D+Sk3h\n\tx2GE/oX5HSPZeTyicCpHmVGumZNKMn+2ZO7DtgzDQ6zXyy0m6a7Xu62cS8VcB7iQnmoG\n\tBiI8RqevtE2KdlmgznQGmtb6seSTS30Z529pBWCk0IfTogef5e9Q8D2VpBHPpiyrrSgM\n\tN8GSIFUe5afMmJr/TBx7Vqmvt4As4HroUXGEI1sLPuP6mVtOZwAwsM56I8xDZP0CGHVn\n\tWnPg==", "X-Gm-Message-State": "ACrzQf05Ifo7x56B+eopMIgcJC8yO8sN+ndxVdxrjKk8W85vsUii2gGH\n\t+XIeWzQuU4dut8Za8Q0Wd+d0wpiHrYvqMg==", "X-Google-Smtp-Source": "AMsMyM5u7cAPb943J/e3IAI7RGi7RHMpDPt6g7bgOejo9r1IJZ5jwme6RrvL+H+tMCe26Qk0epdGrQ==", "X-Received": "by 2002:a5d:6dc2:0:b0:236:5107:f5ba with SMTP id\n\td2-20020a5d6dc2000000b002365107f5bamr22399648wrz.522.1666870807906; \n\tThu, 27 Oct 2022 04:40:07 -0700 (PDT)", "To": "libcamera-devel@lists.libcamera.org", "Date": "Thu, 27 Oct 2022 12:39:56 +0100", "Message-Id": "<20221027113956.7854-1-david.plowman@raspberrypi.com>", "X-Mailer": "git-send-email 2.30.2", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH] ipa: raspberrypi: awb: Update colour\n\ttemperature whenever manual gains change", "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>", "From": "David Plowman via libcamera-devel <libcamera-devel@lists.libcamera.org>", "Reply-To": "David Plowman <david.plowman@raspberrypi.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Previously we only did this when the system starts (on the first\nswitch_mode). Now we do it whenever the manual colour gains are\nupdated. To facilitate this, this R/B vs. colour temperature inverse\nfunctions are stored persistently in the AwbConfig.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\n---\n src/ipa/raspberrypi/controller/rpi/awb.cpp | 24 +++++++++-------------\n src/ipa/raspberrypi/controller/rpi/awb.h | 3 ++-\n 2 files changed, 12 insertions(+), 15 deletions(-)", "diff": "diff --git a/src/ipa/raspberrypi/controller/rpi/awb.cpp b/src/ipa/raspberrypi/controller/rpi/awb.cpp\nindex 2b88c3b0..8d8ddf09 100644\n--- a/src/ipa/raspberrypi/controller/rpi/awb.cpp\n+++ b/src/ipa/raspberrypi/controller/rpi/awb.cpp\n@@ -104,6 +104,9 @@ int AwbConfig::read(const libcamera::YamlObject ¶ms)\n \t\tret = readCtCurve(ctR, ctB, params[\"ct_curve\"]);\n \t\tif (ret)\n \t\t\treturn ret;\n+\t\t/* We will want the inverse functions of these too. */\n+\t\tctRInverse = ctR.inverse();\n+\t\tctBInverse = ctB.inverse();\n \t}\n \n \tif (params.contains(\"priors\")) {\n@@ -174,7 +177,6 @@ Awb::Awb(Controller *controller)\n \tasyncAbort_ = asyncStart_ = asyncStarted_ = asyncFinished_ = false;\n \tmode_ = nullptr;\n \tmanualR_ = manualB_ = 0.0;\n-\tfirstSwitchMode_ = true;\n \tasyncThread_ = std::thread(std::bind(&Awb::asyncFunc, this));\n }\n \n@@ -270,27 +272,21 @@ void Awb::setManualGains(double manualR, double manualB)\n \t\tsyncResults_.gainR = prevSyncResults_.gainR = manualR_;\n \t\tsyncResults_.gainG = prevSyncResults_.gainG = 1.0;\n \t\tsyncResults_.gainB = prevSyncResults_.gainB = manualB_;\n+\t\tif (config_.bayes) {\n+\t\t\t/* Also estimate the best corresponding colour temperature from the curves. */\n+\t\t\tdouble ctR = config_.ctRInverse.eval(config_.ctRInverse.domain().clip(1 / manualR_));\n+\t\t\tdouble ctB = config_.ctBInverse.eval(config_.ctBInverse.domain().clip(1 / manualB_));\n+\t\t\tprevSyncResults_.temperatureK = (ctR + ctB) / 2;\n+\t\t\tsyncResults_.temperatureK = prevSyncResults_.temperatureK;\n+\t\t}\n \t}\n }\n \n void Awb::switchMode([[maybe_unused]] CameraMode const &cameraMode,\n \t\t Metadata *metadata)\n {\n-\t/*\n-\t * On the first mode switch we'll have no meaningful colour\n-\t * temperature, so try to dead reckon one if in manual mode.\n-\t */\n-\tif (!isAutoEnabled() && firstSwitchMode_ && config_.bayes) {\n-\t\tPwl ctRInverse = config_.ctR.inverse();\n-\t\tPwl ctBInverse = config_.ctB.inverse();\n-\t\tdouble ctR = ctRInverse.eval(ctRInverse.domain().clip(1 / manualR_));\n-\t\tdouble ctB = ctBInverse.eval(ctBInverse.domain().clip(1 / manualB_));\n-\t\tprevSyncResults_.temperatureK = (ctR + ctB) / 2;\n-\t\tsyncResults_.temperatureK = prevSyncResults_.temperatureK;\n-\t}\n \t/* Let other algorithms know the current white balance values. */\n \tmetadata->set(\"awb.status\", prevSyncResults_);\n-\tfirstSwitchMode_ = false;\n }\n \n bool Awb::isAutoEnabled() const\ndiff --git a/src/ipa/raspberrypi/controller/rpi/awb.h b/src/ipa/raspberrypi/controller/rpi/awb.h\nindex cb4cfd1b..30acd89d 100644\n--- a/src/ipa/raspberrypi/controller/rpi/awb.h\n+++ b/src/ipa/raspberrypi/controller/rpi/awb.h\n@@ -42,6 +42,8 @@ struct AwbConfig {\n \tbool fast; /* \"fast\" mode uses a 16x16 rather than 32x32 grid */\n \tPwl ctR; /* function maps CT to r (= R/G) */\n \tPwl ctB; /* function maps CT to b (= B/G) */\n+\tPwl ctRInverse; /* inverse of ctR */\n+\tPwl ctBInverse; /* inverse of ctB */\n \t/* table of illuminant priors at different lux levels */\n \tstd::vector<AwbPrior> priors;\n \t/* AWB \"modes\" (determines the search range) */\n@@ -168,7 +170,6 @@ private:\n \tdouble manualR_;\n \t/* manual b setting */\n \tdouble manualB_;\n-\tbool firstSwitchMode_; /* is this the first call to SwitchMode? */\n };\n \n static inline Awb::RGB operator+(Awb::RGB const &a, Awb::RGB const &b)\n", "prefixes": [ "libcamera-devel" ] }