From patchwork Thu Jan 9 11:53:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 22487 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 01B90C32EA for ; Thu, 9 Jan 2025 11:55:08 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9916C684E2; Thu, 9 Jan 2025 12:55:07 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="uLoAT3Va"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6905061891 for ; Thu, 9 Jan 2025 12:55:05 +0100 (CET) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:93b9:eca8:897d:eae6]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 980135B3; Thu, 9 Jan 2025 12:54:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1736423651; bh=9nvtIRHdC9iG7g0qs4U4uzGMbofIs7YxteVBIY5gJsc=; h=From:To:Cc:Subject:Date:From; b=uLoAT3VaVyqEGwLvqESr6lpgWmqWn2bUnTkH2x1fvdHyprY/9oYogbNKfpEaNW4T3 WG9xNRe9ewljOeGhO9mmhyeJqkAX93ByF/DlQPpgqhka6Y+4YDZYgpi88wJzH6bJPF yVAALm9GYyPyWZ3XDcJBlLPMEDJ95Pv0IHNg54J8= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v1 00/11] Add Bayesian AWB algorithm to libipa and rkisp1 Date: Thu, 9 Jan 2025 12:53:51 +0100 Message-ID: <20250109115412.356768-1-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 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 Bayesian AWB algorithm improves the AWB performance by taking prior likelihoods for a colour temperature given a measured lux level into account. The algorithm was first implemented by RaspberryPi and is documented in the RaspberryPi camera guide. This series takes that implementation and adapts it for the use on libipa and the rkisp1 pipeline. It still keeps the grey world algorithm as a fallback or as a simple alternative that does not require any tuning. Patches 1-2 add small utility functions in lipia. Patches 3-7 prepare for the bayes AWB integration. First some base classes are added to be able to implement different AWB algorithms with a common interface. Then the grey world algorithm from rkisp1 is moved into libipa. Patches 8-10 add the bayes AWB algorithm to libtuning and libipa and integrate it into the rkisp1 IPA. Patch 13 is a small fix to start the camera with better default gains. The integration of the actual lux measurements from the Lux algorithm is missing in this series and will be added in an upcoming version. Best regards, Stefan Stefan Klug (11): libipa: interpolator: Add accessor to internal data libipa: pwl: Add clear() function libipa: Add AWB algorithm base class libipa: awb: Add helper functions for AWB mode support libipa: Add grey world AWB algorithm ipa: rkisp1: Move calculation of RGB means into own function ipa: rkisp1: Use grey world algorithm from libipa libtuning: module: awb: Add bayes AWB support libipa: Add bayesian AWB algorithm ipa: rkisp1: Add support for bayes AWB algorithm from libipa ipa: rkisp1: awb: Apply gains based on default colour temperature on start src/ipa/libipa/awb.cpp | 237 ++++++++++ src/ipa/libipa/awb.h | 63 +++ src/ipa/libipa/awb_bayes.cpp | 457 +++++++++++++++++++ src/ipa/libipa/awb_bayes.h | 67 +++ src/ipa/libipa/awb_grey.cpp | 114 +++++ src/ipa/libipa/awb_grey.h | 35 ++ src/ipa/libipa/interpolator.cpp | 10 +- src/ipa/libipa/interpolator.h | 5 + src/ipa/libipa/meson.build | 6 + src/ipa/libipa/pwl.cpp | 5 + src/ipa/libipa/pwl.h | 1 + src/ipa/rkisp1/algorithms/awb.cpp | 171 ++++--- src/ipa/rkisp1/algorithms/awb.h | 7 +- utils/tuning/config-example.yaml | 34 +- utils/tuning/libtuning/modules/awb/awb.py | 16 +- utils/tuning/libtuning/modules/awb/rkisp1.py | 21 +- 16 files changed, 1178 insertions(+), 71 deletions(-) create mode 100644 src/ipa/libipa/awb.cpp create mode 100644 src/ipa/libipa/awb.h create mode 100644 src/ipa/libipa/awb_bayes.cpp create mode 100644 src/ipa/libipa/awb_bayes.h create mode 100644 src/ipa/libipa/awb_grey.cpp create mode 100644 src/ipa/libipa/awb_grey.h