From patchwork Thu Dec 2 18:04:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Michel Hautbois X-Patchwork-Id: 14994 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 37844BDB13 for ; Thu, 2 Dec 2021 18:04:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7896060832; Thu, 2 Dec 2021 19:04:17 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="T2/DgtuB"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AAE916011A for ; Thu, 2 Dec 2021 19:04:15 +0100 (CET) Received: from tatooine.ideasonboard.com (unknown [IPv6:2a01:e0a:169:7140:7fc3:78ca:aeee:c4f2]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4E367464; Thu, 2 Dec 2021 19:04:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1638468255; bh=bRclG9sLtT4Spk9m2k76VMa8LtbCee6iFa5tATRC0AY=; h=From:To:Cc:Subject:Date:From; b=T2/DgtuB8mSSpq6T7o48izwH8iz/PJax6+NNlc0HxuazXQMZxOsoT6ItKPV+9bzUd k8MleYI8Kxqgw9uySnR3BwOnML+GgVlMYs4iSVGAQ6NDCqusmz9t9WEljEdgvqdRIQ j+Os+RdByVGeIHeIVAmZGVj2lbY8uV04sGmNvQOQ= From: Jean-Michel Hautbois To: libcamera-devel@lists.libcamera.org Date: Thu, 2 Dec 2021 19:04:04 +0100 Message-Id: <20211202180410.518232-1-jeanmichel.hautbois@ideasonboard.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 0/6] 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Hello, This series introduces several algorithms or tuning parameters for the RkISP1 IPA. First, the imx219 is a non linear CMOS sensor and its channels are compressed. In order to have a better exposed output frame, we need to apply a deGamma curve on the raw pixels, which is done by a simple look-up table on the ISP side. The values are taken from the imx219.json tuning file in the RPi IPA. The next algorithm is the black level correction. The output is washed out if no black correction is applied. Again, use the tuning values from the imx219 data file in RPi. Now, we 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. Next, the color correction matric needs to be a bit modified as the default one is a simple identity matrix. A very simple estimation uses the red and blue gains calculated but a real tuning file would be better, based on color temperature as the imx219 data file. Last patch 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. I wanted to post captured images for each of those algorithm to see the evolution but I accidentaly broke my sd card connector... and I am now stuck until I can repair it... :-( Jean-Michel Hautbois (6): ipa: rkisp1: Introduce sensor degamma ipa: rkisp1: Use frame index ipa: rkisp1: Introduce Black Level Correction ipa: rkisp1: Introduce AWB ipa: rkisp1: Introduce crosstalk correction ipa: rkisp1: agc: Introduce histogram calculation src/ipa/rkisp1/algorithms/agc.cpp | 92 +++++++++++++--- src/ipa/rkisp1/algorithms/agc.h | 4 +- src/ipa/rkisp1/algorithms/awb.cpp | 149 ++++++++++++++++++++++++++ src/ipa/rkisp1/algorithms/awb.h | 33 ++++++ src/ipa/rkisp1/algorithms/blc.cpp | 55 ++++++++++ src/ipa/rkisp1/algorithms/blc.h | 30 ++++++ src/ipa/rkisp1/algorithms/ctk.cpp | 59 ++++++++++ src/ipa/rkisp1/algorithms/ctk.h | 30 ++++++ src/ipa/rkisp1/algorithms/meson.build | 4 + src/ipa/rkisp1/algorithms/sdg.cpp | 49 +++++++++ src/ipa/rkisp1/algorithms/sdg.h | 30 ++++++ src/ipa/rkisp1/ipa_context.cpp | 33 ++++++ src/ipa/rkisp1/ipa_context.h | 19 ++++ src/ipa/rkisp1/rkisp1.cpp | 19 ++-- 14 files changed, 583 insertions(+), 23 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 create mode 100644 src/ipa/rkisp1/algorithms/ctk.cpp create mode 100644 src/ipa/rkisp1/algorithms/ctk.h create mode 100644 src/ipa/rkisp1/algorithms/sdg.cpp create mode 100644 src/ipa/rkisp1/algorithms/sdg.h Tested-by: Peter Griffin