Show a patch.

GET /api/patches/22497/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 22497,
    "url": "https://patchwork.libcamera.org/api/patches/22497/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/22497/",
    "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": "<20250109115412.356768-11-stefan.klug@ideasonboard.com>",
    "date": "2025-01-09T11:54:01",
    "name": "[v1,10/11] ipa: rkisp1: Add support for bayes AWB algorithm from libipa",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "e108b7cdcb642c8174cc036020cd644faf18b41e",
    "submitter": {
        "id": 184,
        "url": "https://patchwork.libcamera.org/api/people/184/?format=api",
        "name": "Stefan Klug",
        "email": "stefan.klug@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/22497/mbox/",
    "series": [
        {
            "id": 4938,
            "url": "https://patchwork.libcamera.org/api/series/4938/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4938",
            "date": "2025-01-09T11:53:51",
            "name": "Add Bayesian AWB algorithm to libipa and rkisp1",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/4938/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/22497/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/22497/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 3E4E8C32EA\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  9 Jan 2025 11:55:39 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CCB136854E;\n\tThu,  9 Jan 2025 12:55:38 +0100 (CET)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2C0C36854B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  9 Jan 2025 12:55:32 +0100 (CET)",
            "from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:93b9:eca8:897d:eae6])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 898A65B3;\n\tThu,  9 Jan 2025 12:54:38 +0100 (CET)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"ksFaXMYv\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1736423678;\n\tbh=/DuFEHPaZsM3vdI7ESRF992+IXEEYo800VfIGt5f5Ug=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=ksFaXMYvqm15PIQLKVNSiSsKkb4Uir5+1Z1Bp2JnPV7RV8v1x6BSc6INn5A56WtFr\n\tuvHGa3VpgfI19t0yui2aCWkMkkRIO34Lww6XJPEFdSbZOf4XoEEUVSvYczo+8xdxMT\n\t/R4zqrdks5+Eg4hGWOnivd2K0fcIs0tQTB6aV+OM=",
        "From": "Stefan Klug <stefan.klug@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Stefan Klug <stefan.klug@ideasonboard.com>",
        "Subject": "[PATCH v1 10/11] ipa: rkisp1: Add support for bayes AWB algorithm\n\tfrom libipa",
        "Date": "Thu,  9 Jan 2025 12:54:01 +0100",
        "Message-ID": "<20250109115412.356768-11-stefan.klug@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.43.0",
        "In-Reply-To": "<20250109115412.356768-1-stefan.klug@ideasonboard.com>",
        "References": "<20250109115412.356768-1-stefan.klug@ideasonboard.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": "Now that libipa contains a bayes AWB algorithm, add it as supported\nalgorithm to the rkisp1 ipa.\n\nThe decision between the grey world algorithm and the bayesian is done\nbased on the \"algorithm\" property of the \"Awb\" algorithm in the tuning\nfile.\n\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n---\n\nTodo: The lux level is currently hardcoded to 1000. The result from the\nlux estimation needs to be used here.\n---\n src/ipa/rkisp1/algorithms/awb.cpp | 44 ++++++++++++++++++++++++++-----\n 1 file changed, 38 insertions(+), 6 deletions(-)",
    "diff": "diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\nindex 42a4784998bc..39a2c0589943 100644\n--- a/src/ipa/rkisp1/algorithms/awb.cpp\n+++ b/src/ipa/rkisp1/algorithms/awb.cpp\n@@ -16,6 +16,7 @@\n \n #include <libcamera/ipa/core_ipa_interface.h>\n \n+#include \"libipa/awb_bayes.h\"\n #include \"libipa/awb_grey.h\"\n #include \"libipa/colours.h\"\n \n@@ -45,13 +46,23 @@ class RkISP1AwbStats : public AwbStats\n {\n public:\n \tRkISP1AwbStats(const RGB<double> &rgbMeans)\n-\t\t: rgbMeans_(rgbMeans) {}\n+\t\t: rgbMeans_(rgbMeans)\n+\t{\n+\t\trg_ = rgbMeans_.r() / rgbMeans_.g();\n+\t\tbg_ = rgbMeans_.b() / rgbMeans_.g();\n+\t}\n \n-\tdouble computeColourError([[maybe_unused]] const RGB<double> &gains) const override\n+\tdouble computeColourError(const RGB<double> &gains) const override\n \t{\n-\t\tLOG(RkISP1Awb, Error)\n-\t\t\t<< \"RkISP1AwbStats::computeColourError is not implemented\";\n-\t\treturn 0.0;\n+\t\t/*\n+\t\t* Compute the sum of the squared colour error (non-greyness) as it\n+\t\t* appears in the log likelihood equation.\n+\t\t*/\n+\t\tdouble deltaR = gains.r() * rg_ - 1.0;\n+\t\tdouble deltaB = gains.b() * bg_ - 1.0;\n+\t\tdouble delta2 = deltaR * deltaR + deltaB * deltaB;\n+\n+\t\treturn delta2;\n \t}\n \n \tRGB<double> getRGBMeans() const override\n@@ -61,6 +72,8 @@ public:\n \n private:\n \tRGB<double> rgbMeans_;\n+\tdouble rg_;\n+\tdouble bg_;\n };\n \n Awb::Awb()\n@@ -78,13 +91,30 @@ int Awb::init(IPAContext &context, const YamlObject &tuningData)\n \t\t\t\t\t\t\t kMaxColourTemperature,\n \t\t\t\t\t\t\t kDefaultColourTemperature);\n \n-\tawbAlgo_ = std::make_unique<AwbGrey>();\n+\tif (!tuningData.contains(\"algorithm\"))\n+\t\tLOG(RkISP1Awb, Info) << \"No awb algorithm specified.\"\n+\t\t\t\t     << \" Default to grey world\";\n+\n+\tauto mode = tuningData[\"algorithm\"].get<std::string>(\"grey\");\n+\tif (mode == \"grey\") {\n+\t\tawbAlgo_ = std::make_unique<AwbGrey>();\n+\t} else if (mode == \"bayes\") {\n+\t\tawbAlgo_ = std::make_unique<AwbBayes>();\n+\t} else {\n+\t\tLOG(RkISP1Awb, Error) << \"Unknown awb algorithm: \" << mode;\n+\t\treturn -EINVAL;\n+\t}\n+\tLOG(RkISP1Awb, Debug) << \"Using awb algorithm: \" << mode;\n+\n \tint ret = awbAlgo_->init(tuningData);\n \tif (ret) {\n \t\tLOG(RkISP1Awb, Error) << \"Failed to init awb algorithm\";\n \t\treturn ret;\n \t}\n \n+\tconst auto &src = awbAlgo_->controls();\n+\tcmap.insert(src.begin(), src.end());\n+\n \treturn 0;\n }\n \n@@ -131,6 +161,8 @@ void Awb::queueRequest(IPAContext &context,\n \t\t\t<< (*awbEnable ? \"Enabling\" : \"Disabling\") << \" AWB\";\n \t}\n \n+\tawbAlgo_->handleControls(controls);\n+\n \tframeContext.awb.autoEnabled = awb.autoEnabled;\n \n \tif (awb.autoEnabled)\n",
    "prefixes": [
        "v1",
        "10/11"
    ]
}