From patchwork Mon Mar 28 09:24:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Michel Hautbois X-Patchwork-Id: 15563 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 16E0BC3256 for ; Mon, 28 Mar 2022 09:24:44 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 27DA96559A; Mon, 28 Mar 2022 11:24:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1648459483; bh=hytdgAxGi65jV6H4WXuvywTWH/TOUdKcb7p8p98skyE=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=F0dAG4kHxf58oKNbOephpSWNq1xUYLk4ROS4bKY1o6QQ1atK4/9oOhQKTTOCuDRQy SRlVIf9w5l63PJ9aZ0iONYl7Go+atVC5KaOI/LtOTwPyc1F4abyAqe38nArhsqJDiH j7w65/B5tCbpQEtpIEKBsTh/W5bVyMEqw0KgpMXl949ATAcrlzuGnyBbWIPXF5PMru 9r3Rj84s3VEP+Fs32HLPza7mImE41MLWFZOpNCJYNKcIzXzZ5PJXjQg+hvxYi07qVk C9RrNReTq6ifRDxHiewZCXhLSjeYxR/ZoWg3bVV0J6AFuVrKnHDe7WF7Uwdh+bTbLk MFNOpwhKlaTIQ== 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 8EDEF604BF for ; Mon, 28 Mar 2022 11:24:41 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="atA90Pd2"; dkim-atps=neutral Received: from tatooine.ideasonboard.com (unknown [IPv6:2a01:e0a:169:7140:4f49:c672:4655:7dbb]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 36D5E9BC; Mon, 28 Mar 2022 11:24:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1648459481; bh=hytdgAxGi65jV6H4WXuvywTWH/TOUdKcb7p8p98skyE=; h=From:To:Cc:Subject:Date:From; b=atA90Pd2OxHfvXLFJdK58tJ+3R9DyL9H4gXTOON0oHREb/JxOY/hF+WL9ty8nG+5J tPSzHmv4LpHFWcWonLpE4q/M7Qe+D2/PeU0Qz97tDCZ+SPLByWwM+3kiHslRLZabWz iYfL6R7wZotYewYs2jCsXhXCzSYh2+hjo+Dhu7wE= To: libcamera-devel@lists.libcamera.org Date: Mon, 28 Mar 2022 11:24:28 +0200 Message-Id: <20220328092433.69856-1-jeanmichel.hautbois@ideasonboard.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 0/5] IPA RkISP1 awb and misc improvements 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: , X-Patchwork-Original-From: Jean-Michel Hautbois via libcamera-devel From: Jean-Michel Hautbois Reply-To: Jean-Michel Hautbois Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Hello, This series introduces several algorithms or tuning parameters for the RkISP1 IPA. The first algorithm is the black level correction. The output is washed out if no black correction is applied. It uses the tuning values from the imx219 data file in RPi. Patch 3/5 introduced in v3 makes the Histogram class able to use const uint32_t arrays. Patch 4/5 introduces the histogram IQ mean estimation as for the IPU3 and uses the maximum of the relative luminance gain and the iqMean gain to determine the shutter speed and analogue gain to apply. Now, patch 5/5 can estimate the AWB gains to apply on the red and blue channels. The RkISP1 could theoretically give us the red, green and blue mean values for the current frame, but the kernel seems to lack support for this. Use the YCrCb estimation instead, and convert the values to RGB before estimating the gains. We don't have a grid of average values, only a global mean for each channel. I have removed two algorithms from this series: sensor degamma and crosstalk matrix. Those need a bit more work (sdg curve may be the wrong one according to the previous review, and the crosstalk matrix is not a tuned one). I have made some captures (qcam seems to invert width and height when saving the image though): [1]: agc only (current master): https://snipboard.io/dFO23J.jpg [2]: [1] with histogram and black level: https://snipboard.io/fd9zC2.jpg [3]: [2] with awb: https://snipboard.io/Sp9Ei6.jpg This is the state with this v2 series applied on top of master. And for the record, I picked the previous sdg and ctk algorithms to capture with those: [4]: [3] with sensor degamma: https://snipboard.io/5QO46g.jpg [5]: [4] with crosstalk matrix: https://snipboard.io/tDOV7l.jpg Jean-Michel Hautbois (5): ipa: rkisp1: Use frame counter for the request queued ipa: rkisp1: Introduce Black Level Correction ipa: libipa: Histogram: Constify the constructor span ipa: rkisp1: agc: Add a histogram-based gain ipa: rkisp1: Introduce AWB src/ipa/libipa/histogram.cpp | 2 +- src/ipa/libipa/histogram.h | 2 +- src/ipa/rkisp1/algorithms/agc.cpp | 91 +++++++++++-- src/ipa/rkisp1/algorithms/agc.h | 6 +- src/ipa/rkisp1/algorithms/awb.cpp | 178 ++++++++++++++++++++++++++ src/ipa/rkisp1/algorithms/awb.h | 33 +++++ src/ipa/rkisp1/algorithms/blc.cpp | 57 +++++++++ src/ipa/rkisp1/algorithms/blc.h | 30 +++++ src/ipa/rkisp1/algorithms/meson.build | 2 + src/ipa/rkisp1/ipa_context.cpp | 42 +++++- src/ipa/rkisp1/ipa_context.h | 21 ++- src/ipa/rkisp1/rkisp1.cpp | 7 + 12 files changed, 452 insertions(+), 19 deletions(-) create mode 100644 src/ipa/rkisp1/algorithms/awb.cpp create mode 100644 src/ipa/rkisp1/algorithms/awb.h create mode 100644 src/ipa/rkisp1/algorithms/blc.cpp create mode 100644 src/ipa/rkisp1/algorithms/blc.h