From patchwork Thu Apr 3 15:49:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 23116 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 447A7C327D for ; Thu, 3 Apr 2025 15:49:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0E956689A1; Thu, 3 Apr 2025 17:49:37 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="lORGyOS3"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3900068980 for ; Thu, 3 Apr 2025 17:49:35 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:6d9d:9854:3fc1:4bb2]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 6E7388FA; Thu, 3 Apr 2025 17:47:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1743695261; bh=vuF0Hteiz0VvXO5Pec77ZE5UkVPYJcHndEfuw0sr0Do=; h=From:To:Cc:Subject:Date:From; b=lORGyOS3jklwI2WHv2MnFJc6UFWJFsW/FdyRcKEyCj2wcynu4a1E7M/bZcYE9tlGO WyIJD+/ffcp410g4Uis+JvQ9riacJpEXGGiy0DUHDkB/EFhd6J8BKfpPKnWLLm+VkH +tte21xvICKG3OPcGcUcGVii8GL97Jw8uofFT9s8= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v3 00/16] Some rkisp1 awb improvements Date: Thu, 3 Apr 2025 17:49:05 +0200 Message-ID: <20250403154925.382973-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" Hi all, This series contains a few fixes that greatly improve and stabilize the AWB handling on rkisp1. After the feedback from the first version, some parts were rewritten and Laurent added a generic matrix inverse function. Patches 1-8 add utility functions to Vector and Matrix. The rest fixes some bugs and generally improves the AWB on rkisp1. Please see the individual patches for details. Best regards, Stefan Changes in v2: - Replaced the matrix cast() and inverse() functions by better alternatives - Added a manual CCM control - Some small fixes (see logs in individual patches) Changes in v3: - Included feedback from review (See individual changelogs) - Split patch 10 into 10 and 11 - Dropped patch 13 (Use gains from color temperature curve) because it was actually doing the wrong thing when bayesian awb was active and the benefit was not that big anymore, now that bayesian awb is available. - Dropped patch 15 (Set rgb mean limits to 180) because it was not really necessary and the description was not sufficient. Laurent Pinchart (2): libcamera: matrix: Extend multiplication operator to heterogenous types libcamera: vector: Extend matrix multiplication operator to heterogenous types Stefan Klug (14): libcamera: matrix: Replace SFINAE with static_asserts libcamera: matrix: Make most functions constexpr libcamera: matrix: Add a Span based constructor libcamera: vector: Add a Span based constructor libcamera: matrix: Add inverse() function test: Add minimal test for Matrix ipa: rkisp1: Refactor automatic/manual structure in IPAActiveState ipa: rkisp1: algorithms: awb: Fix wrong colour temperature reporting ipa: rkisp1: ccm/lsc: Fix CCM/LSC based on manual color temperature ipa: rkisp1: Implement manual ColourCorrectionMatrix control libipa: awb: Make result of gainsFromColourTemp optional ipa: rkisp1: Damp color temperature regulation ipa: rkisp1: awb: Take the CCM into account for the AWB gains calculation ipa: rkisp1: awb: Avoid division by zero include/libcamera/internal/matrix.h | 71 +++++++---- include/libcamera/internal/vector.h | 17 ++- src/ipa/libipa/awb.cpp | 2 +- src/ipa/libipa/awb.h | 3 +- src/ipa/libipa/awb_bayes.cpp | 4 +- src/ipa/libipa/awb_bayes.h | 2 +- src/ipa/libipa/awb_grey.cpp | 6 +- src/ipa/libipa/awb_grey.h | 2 +- src/ipa/rkisp1/algorithms/awb.cpp | 64 ++++++---- src/ipa/rkisp1/algorithms/awb.h | 2 - src/ipa/rkisp1/algorithms/ccm.cpp | 66 ++++++++-- src/ipa/rkisp1/algorithms/ccm.h | 6 + src/ipa/rkisp1/algorithms/lsc.cpp | 6 +- src/ipa/rkisp1/ipa_context.cpp | 36 ++++-- src/ipa/rkisp1/ipa_context.h | 15 ++- src/libcamera/matrix.cpp | 181 +++++++++++++++++++++++++++- src/libcamera/vector.cpp | 13 +- test/matrix.cpp | 53 ++++++++ test/meson.build | 1 + 19 files changed, 455 insertions(+), 95 deletions(-) create mode 100644 test/matrix.cpp