From patchwork Thu Nov 24 11:38:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 17880 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 C14ECBE08B for ; Thu, 24 Nov 2022 11:39:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8CF4E6331E; Thu, 24 Nov 2022 12:39:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1669289944; bh=GNpywXg/yKexz4YE18N9donLS2yBn68Rnq+bjYOsli0=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=yqnvgLx36oLlPb73NLHOlyLmtloNErnuHg0cEgWybiirYawvaSW+1wgXaJYFiNfJt p1TbQLbyg0L/3iuUjSUdh9554jMrk/cSjnx3uSH85iUD1A5GDzU/cC+r96ilRnpFGl y06Q3UGgwV3Swct8YePfiB+yVoNgxLj3x5pJC0VTuwpZdK82n0F4OOXaqPpyTC1ZCk VGYdSY9i7lt8bv8zaleVmJ6nkODXpaVjCIzT+GQiDXUuT0KqTQ3hsc2qCEDRk2aety pl58Hb+q2vDKo1rNXxHtomJgUt3PE/AZDlAiKLcyWP8TsyaAY7tcxKjL7BmdYIAX52 E2rNDu0EnNXtQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5543C63313 for ; Thu, 24 Nov 2022 12:39:02 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="feIdwJG3"; dkim-atps=neutral Received: from pyrite.tail37cf.ts.net (h175-177-042-159.catv02.itscom.jp [175.177.42.159]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1EF34496; Thu, 24 Nov 2022 12:39:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1669289942; bh=GNpywXg/yKexz4YE18N9donLS2yBn68Rnq+bjYOsli0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=feIdwJG3IMsjHZEIdUFh9BbJ5PivlS/ZRQg+F2+A/k56Sr8BOk5Si6UFOtUq6HZoA hq8AApdXi1Fq5vXH5kISX1xj06RtNNAXoe9xw5tW5tHt9et6Tc88TUFw2LSAoS5ly7 MU3r5CxxH688VVK6p7rCiaQezQ+JUgInIn0N+Hwo= To: libcamera-devel@lists.libcamera.org Date: Thu, 24 Nov 2022 20:38:44 +0900 Message-Id: <20221124113849.2193579-2-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221124113849.2193579-1-paul.elder@ideasonboard.com> References: <20221124113849.2193579-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/6] utils: libtuning: module: Prepare per-module debugging infrastructure 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: Paul Elder via libcamera-devel From: Paul Elder Reply-To: Paul Elder Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Prepare for per-module debugging infrastructure in the base Module class. The debug parameter will be provided from a command line argument as opposed to from the tuning script as was originally planned. Remove the debug parameter from the LSC constructor (it is the only module that we have so far). As the debug parameter currently does not do anything, no regression is introduced. Update the tuning scripts accordingly. Signed-off-by: Paul Elder Reviewed-by: Daniel Scally --- utils/tuning/libtuning/modules/lsc/lsc.py | 3 --- utils/tuning/libtuning/modules/module.py | 6 ++++++ utils/tuning/raspberrypi/alsc.py | 1 - utils/tuning/rkisp1.py | 1 - 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/utils/tuning/libtuning/modules/lsc/lsc.py b/utils/tuning/libtuning/modules/lsc/lsc.py index 344a07a3..f54ca8be 100644 --- a/utils/tuning/libtuning/modules/lsc/lsc.py +++ b/utils/tuning/libtuning/modules/lsc/lsc.py @@ -17,7 +17,6 @@ class LSC(Module): out_name = 'GenericLSC' def __init__(self, *, - debug: list, sector_shape: tuple, sector_x_gradient: lt.Gradient, sector_y_gradient: lt.Gradient, @@ -25,8 +24,6 @@ class LSC(Module): smoothing_function: lt.Smoothing): super().__init__() - self.debug = debug - self.sector_shape = sector_shape self.sector_x_gradient = sector_x_gradient self.sector_y_gradient = sector_y_gradient diff --git a/utils/tuning/libtuning/modules/module.py b/utils/tuning/libtuning/modules/module.py index 12e2fc7c..b4ad0625 100644 --- a/utils/tuning/libtuning/modules/module.py +++ b/utils/tuning/libtuning/modules/module.py @@ -4,6 +4,8 @@ # # module.py - Base class for algorithm-specific tuning modules +from pathlib import Path + # @var type Type of the module. Defined in the base module. # @var out_name The key that will be used for the algorithm in the algorithms @@ -15,8 +17,12 @@ class Module(object): out_name = 'GenericAlgorithm' def __init__(self): + self.debug = None pass + def enable_debug(self, output_dir: Path): + self.debug = output_dir + def validate_config(self, config: dict) -> bool: raise NotImplementedError diff --git a/utils/tuning/raspberrypi/alsc.py b/utils/tuning/raspberrypi/alsc.py index 024eb5a3..4dc5f5ba 100644 --- a/utils/tuning/raspberrypi/alsc.py +++ b/utils/tuning/raspberrypi/alsc.py @@ -10,7 +10,6 @@ from libtuning.modules.lsc import ALSCRaspberryPi ALSC = \ ALSCRaspberryPi(do_color=lt.Param('do_alsc_colour', lt.Param.Mode.Optional, True), luminance_strength=lt.Param('luminance_strength', lt.Param.Mode.Optional, 0.5), - debug=[lt.Debug.Plot], sector_shape=(16, 12), sector_x_gradient=lt.gradient.Linear(lt.Remainder.DistributeFront), sector_y_gradient=lt.gradient.Linear(lt.Remainder.DistributeFront), diff --git a/utils/tuning/rkisp1.py b/utils/tuning/rkisp1.py index 1cea6ddb..43b4b190 100755 --- a/utils/tuning/rkisp1.py +++ b/utils/tuning/rkisp1.py @@ -14,7 +14,6 @@ from libtuning.modules.lsc import LSCRkISP1 tuner = lt.Tuner('RkISP1') tuner.add(LSCRkISP1( - debug=[lt.Debug.Plot], # This is for the actual LSC tuning, and is part of the base LSC # module. rkisp1's table sector sizes (16x16 programmed as mirrored # 8x8) are separate, and is hardcoded in its specific LSC tuning From patchwork Thu Nov 24 11:38:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 17881 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 C2110BE08B for ; Thu, 24 Nov 2022 11:39:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0B9D26331A; Thu, 24 Nov 2022 12:39:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1669289945; bh=Z/yJL/95+L0S96C27txC4U2nwa7r5KzEKzQv4GvU1YQ=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=zDfxMCtexbg3wf504VLtkMTTGRbi+GLGo6+09/YyM7Q31nXDptgFnmhvLYqK3Y6Nb e6ExaWE4aCRd8BRa52jEiEiz1fhVcHxtpvHCBmnmie2T3U0N57TZos5aNcut660WcY wMV2zL4nVxdN5HoXImp/XBAJp9HvF/YU/w6Q+Y0XZfk4/x+3lt+vnSVHubYmVoaNrU QGNAK1n++iol9RqJXlr/g/xL3B4zlOCTdNvcuftYpiu4KuOCtNW3Mkm9vokNzM12HZ AlH2W0YyX91qyzkG/pj0KAeCHFJjWGjjxMQeQtAThQT7MpWXhJuck+Mwc6bYekAZ96 xoyxcpjAkCdmQ== 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 D976C632EA for ; Thu, 24 Nov 2022 12:39:03 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="VJiFhVfM"; dkim-atps=neutral Received: from pyrite.tail37cf.ts.net (h175-177-042-159.catv02.itscom.jp [175.177.42.159]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A30CB496; Thu, 24 Nov 2022 12:39:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1669289943; bh=Z/yJL/95+L0S96C27txC4U2nwa7r5KzEKzQv4GvU1YQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VJiFhVfMwDtW3qRv5TB6JLzzZAhBgbKR1lHVl+F9EPveFNG7pYE4S2z6mV2zAwCni Wa/npr4rSgPfPmINmb63GVvuqR/7SDIxmrY3voqQ+Pm1Fb0O+VqagKeAHdTCp1DMoV sBqvnkxkvvi9Zy2HRU3QexS/3E2IRL2ibymaJcQA= To: libcamera-devel@lists.libcamera.org Date: Thu, 24 Nov 2022 20:38:45 +0900 Message-Id: <20221124113849.2193579-3-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221124113849.2193579-1-paul.elder@ideasonboard.com> References: <20221124113849.2193579-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/6] utils: libtuning: modules: lsc: Add debug plot function 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: Paul Elder via libcamera-devel From: Paul Elder Reply-To: Paul Elder Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a helper function to the base LSC class for plotting an LSC table. This will be used by LSC specializations for debugging pruposes. Signed-off-by: Paul Elder --- utils/tuning/libtuning/modules/lsc/lsc.py | 31 +++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/utils/tuning/libtuning/modules/lsc/lsc.py b/utils/tuning/libtuning/modules/lsc/lsc.py index f54ca8be..4d580ad4 100644 --- a/utils/tuning/libtuning/modules/lsc/lsc.py +++ b/utils/tuning/libtuning/modules/lsc/lsc.py @@ -8,7 +8,10 @@ from ..module import Module import libtuning as lt import libtuning.utils as utils +import matplotlib.pyplot as plt +from matplotlib import cm import numpy as np +from pathlib import Path class LSC(Module): @@ -67,3 +70,31 @@ class LSC(Module): table = table / np.min(table) return table, grid + + def _plot_single_lsc(self, image: lt.Image, cr: np.array, cb: np.array, + cg1: np.array, cg2: np.array = None): + hf = plt.figure(figsize=(8, 8)) + # Y is plotted as -Y so plot has same axes as image + X, Y = np.meshgrid(range(self.sector_shape[0]), range(self.sector_shape[1])) + + ha = hf.add_subplot(221 if cg2 is not None else 311, projection='3d') + ha.plot_surface(X, -Y, cr, cmap=cm.coolwarm, linewidth=0) + ha.set_title(f'{self.hr_name} Plot\nImage: {image.name}\n\ncr') + + hb = hf.add_subplot(222 if cg2 is not None else 312, projection='3d') + hb.plot_surface(X, -Y, cb, cmap=cm.coolwarm, linewidth=0) + hb.set_title('cb') + + hc = hf.add_subplot(223 if cg2 is not None else 313, projection='3d') + hc.plot_surface(X, -Y, cg1, cmap=cm.coolwarm, linewidth=0) + hc.set_title('gr' if cg2 is not None else 'g') + + if cg2 is not None: + hd = hf.add_subplot(224, projection='3d') + hd.plot_surface(X, -Y, cg2, cmap=cm.coolwarm, linewidth=0) + hd.set_title('gb') + + # The caller will validate self.debug (there's no sense in calling this + # function if self.debug is None anyway) + fname = self.debug / f"{image.name.split('.')[0]}-lsc.png" + plt.savefig(fname) From patchwork Thu Nov 24 11:38:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 17882 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 B7F03BE08B for ; Thu, 24 Nov 2022 11:39:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 753CF63322; Thu, 24 Nov 2022 12:39:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1669289947; bh=FEgg053LJqNPqDZEsgYZ3eXrCiGeZWODHlpvDbrVetU=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=x2xIbwZ2ftUysGfoRHDGuseGM4ob3Jr9BGJsRQZZQXFMTaabCWFb3IY/m908rV/Ut Ii6pyY5zK3Y7y4xTg5zhCdHo87kCvL7akwwEMA7Pe9sBZrgZWB33PS0EInQKnYkzpY S8Scd84/pk4ECBEkOinmKTMeZ6LbxmBq+uKzkg1H4GayssuqQlJwqTLXJYPylFT7gp mKcpUAZqWJ0L/w26ncd18xYnCfiF0gYu1N4ZU8iZCyCEW3UMGUjT8KRN5XDQ+3aXa4 iHq/Ofg4gEDFV00GsJtntnMqhD8B3/ZfF0Da0QtVcFobyCrYcropdWZDIgGFyiVyAh s51oF7ijsDIeQ== 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 5F64F63322 for ; Thu, 24 Nov 2022 12:39:05 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="tP/KUgLG"; dkim-atps=neutral Received: from pyrite.tail37cf.ts.net (h175-177-042-159.catv02.itscom.jp [175.177.42.159]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 31792978; Thu, 24 Nov 2022 12:39:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1669289945; bh=FEgg053LJqNPqDZEsgYZ3eXrCiGeZWODHlpvDbrVetU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tP/KUgLGh0KgdJlXEwy1HEGNbjxiGxn2Csk8zgK1320Oo46FpsFfyJfIvEZyEAswF W42c6ZsYDO5/yei6iK+8UpdXNf8rdj1S9F/Tv9T34tubP3WRKvM0dofzY5KY+83qUs /ftSrKY5AEimmqDakGMXcaZhZoI9bRzJt+u8HJqs= To: libcamera-devel@lists.libcamera.org Date: Thu, 24 Nov 2022 20:38:46 +0900 Message-Id: <20221124113849.2193579-4-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221124113849.2193579-1-paul.elder@ideasonboard.com> References: <20221124113849.2193579-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/6] utils: libtuning: lsc: raspberry: Add per-image debug plotting 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: Paul Elder via libcamera-devel From: Paul Elder Reply-To: Paul Elder Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add debug plotting the LSC table for each image to the Raspberry Pi ALSC module. Signed-off-by: Paul Elder Reviewed-by: Daniel Scally --- utils/tuning/libtuning/modules/lsc/raspberrypi.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utils/tuning/libtuning/modules/lsc/raspberrypi.py b/utils/tuning/libtuning/modules/lsc/raspberrypi.py index 58f5000d..a0298348 100644 --- a/utils/tuning/libtuning/modules/lsc/raspberrypi.py +++ b/utils/tuning/libtuning/modules/lsc/raspberrypi.py @@ -74,7 +74,8 @@ class ALSCRaspberryPi(LSC): cr, _ = self._lsc_single_channel(image.channels[lt.Color.R], image, g) cb, _ = self._lsc_single_channel(image.channels[lt.Color.B], image, g) - # \todo implement debug + if self.debug: + self._plot_single_lsc(image, cr, cb, cg) return image.color, cr.flatten(), cb.flatten(), cg.flatten() From patchwork Thu Nov 24 11:38:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 17883 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 5A3B4BE08B for ; Thu, 24 Nov 2022 11:39:09 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EB0BB63325; Thu, 24 Nov 2022 12:39:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1669289949; bh=SCNNWOpIHHg4gCia+AZuZgl02e8faUO3Gsqf2wem4j0=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=VzYvzJveK+WIy0sttcuosZsQedOrFeAoc0RZF0MRHkSYB1l6IuD5FKGBwFyskKCgI jEVF+SvGDKS6QgogZleoc6el0c74Uvx3o+5lPpnfBOiDrX7qkXu4YIUD6Ug9TCURHw ZadlPelDC7RBPq0/bNlB4CckHkTLjcZfu4jsIcGAlbBe+gzKeM+/QpAmYxdgF/0djK 5zFK41BDLN2Aj7zZ0vHFJy/l2cNLRbZZ1MnMppyz1sqNbnCotoXnt9ku6f6RS6QtjI qtUqrgqByXrGHkwQIHhX2+keSeZk7Ovrp4MnRqEUOKGPqyhaEi/joNrGCRwMo97Xvn nA3d6cjiAagzQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E53A263322 for ; Thu, 24 Nov 2022 12:39:06 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ZfdLChlI"; dkim-atps=neutral Received: from pyrite.tail37cf.ts.net (h175-177-042-159.catv02.itscom.jp [175.177.42.159]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B3D777FA; Thu, 24 Nov 2022 12:39:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1669289946; bh=SCNNWOpIHHg4gCia+AZuZgl02e8faUO3Gsqf2wem4j0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZfdLChlI8I048ov59cB1nkR80+pLaPmwG55mTc87E16VphHsJ6c59BhIXPmE2dA8z Ih3VaEU5zIzqNsggxiCzRCo73UFB7juhouB/AUcKXPAjAy6JT5pXRQYJ46h9Q2Vp9d 8GfCp6jLTZJSH/F6hmRSsDrWVOt7qqhbybml6bL0= To: libcamera-devel@lists.libcamera.org Date: Thu, 24 Nov 2022 20:38:47 +0900 Message-Id: <20221124113849.2193579-5-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221124113849.2193579-1-paul.elder@ideasonboard.com> References: <20221124113849.2193579-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 4/6] utils: libtuning: lsc: rkisp1: Add per-image debug plotting 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: Paul Elder via libcamera-devel From: Paul Elder Reply-To: Paul Elder Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add debug plotting the LSC table for each image to the RkISP1 LSC module. Signed-off-by: Paul Elder Reviewed-by: Daniel Scally --- utils/tuning/libtuning/modules/lsc/rkisp1.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/utils/tuning/libtuning/modules/lsc/rkisp1.py b/utils/tuning/libtuning/modules/lsc/rkisp1.py index 5701ae0a..c3fdcc4f 100644 --- a/utils/tuning/libtuning/modules/lsc/rkisp1.py +++ b/utils/tuning/libtuning/modules/lsc/rkisp1.py @@ -41,6 +41,9 @@ class LSCRkISP1(LSC): cr, _ = self._lsc_single_channel(image.channels[lt.Color.R], image, gr) cb, _ = self._lsc_single_channel(image.channels[lt.Color.B], image, gb) + if self.debug: + self._plot_single_lsc(image, cr, cb, cgr, cgb) + return image.color, cr.flatten(), cb.flatten(), cgr.flatten(), cgb.flatten() # @return List of dictionaries of color temperature, red table, red's green From patchwork Thu Nov 24 11:38:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 17884 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 BC984BE08B for ; Thu, 24 Nov 2022 11:39:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8BF586331C; Thu, 24 Nov 2022 12:39:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1669289950; bh=CRnj4q1I+7B67SEymdsRPb4hXQSqWhGPzt14ZSsaONc=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=bpKQkRQtagIV66VmYgvliFcr2EL1lXhjb+5A2QJ2gehHgF6VzEHfbYofh5ElYIy8/ 7cP65HIeHNzXtvmGFNSHMqJtAb4BNcfvhTXw3fzTDuXQR9m+n81Wk64H5YGscAXZ61 P2AlyN67tI2BAUwHROdp17lUdxE5jFpinHT5POP14u3AdINFNWg+zM5LoSaadEEB7a Np+Cs42/gXO8ofSTejxEhC9a1bvYNYdLG+ed9UxAeYO0+lxpmDCTXsdvafjXPhtFrE oHV1DlDcX/jD35GO4mqxbxO0wvSXGT6JuTI5sqYF5huxoKwOtwWeeTTCe1/6efd0bn RWvLE6Wd6JoqQ== 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 7B263632EA for ; Thu, 24 Nov 2022 12:39:08 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="uDkm64Gt"; dkim-atps=neutral Received: from pyrite.tail37cf.ts.net (h175-177-042-159.catv02.itscom.jp [175.177.42.159]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 42B95496; Thu, 24 Nov 2022 12:39:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1669289948; bh=CRnj4q1I+7B67SEymdsRPb4hXQSqWhGPzt14ZSsaONc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uDkm64Gt7Ge9P0V46vpoLjkZbBGgQwjSJoT0wAqamX6KF5WztrC4LBQJTfCElRX3d JzQ/E3Dt1YD6Xscf14zwrEz7bfNnnhV/5SUwOuJ6KOKpGcnROhOS9rwlAI4TLEYoCW ioXC4k2tKrMvaI1tt2n1D6Jo7JJOnu5LWgHEO0Lk= To: libcamera-devel@lists.libcamera.org Date: Thu, 24 Nov 2022 20:38:48 +0900 Message-Id: <20221124113849.2193579-6-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221124113849.2193579-1-paul.elder@ideasonboard.com> References: <20221124113849.2193579-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 5/6] utils: libtuning: parsers: raspberrypi: Ignore the plot config parameter 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: Paul Elder via libcamera-devel From: Paul Elder Reply-To: Paul Elder Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Ignore the plot config parameter that is used in the Raspberry Pi CTT tuning configuration file, as it conflicts with the debug parameter that will be provided in the command line arguments. Signed-off-by: Paul Elder --- utils/tuning/libtuning/parsers/raspberrypi_parser.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/utils/tuning/libtuning/parsers/raspberrypi_parser.py b/utils/tuning/libtuning/parsers/raspberrypi_parser.py index d26586ba..dab50440 100644 --- a/utils/tuning/libtuning/parsers/raspberrypi_parser.py +++ b/utils/tuning/libtuning/parsers/raspberrypi_parser.py @@ -54,13 +54,9 @@ class RaspberryPiParser(Parser): config.pop('disable') # The raspberrypi config format has 'plot' map to a list of module - # names which should be plotted. libtuning has each module contain the - # plot information in itself so do this conversion. - - for module in self._enumerate_rpi_modules(config['plot'], config, modules): - # It's fine to set the value of a potentially disabled module, as - # the object still exists at this point - module.appendValue('debug', 'plot') + # names which should be plotted. In libtuning, this information is + # passed by command line arguments, so simply drop this piece of + # information. config.pop('plot') # Convert the keys from module name to module instance From patchwork Thu Nov 24 11:38:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 17885 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 38EDFBE08B for ; Thu, 24 Nov 2022 11:39:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EF0E763322; Thu, 24 Nov 2022 12:39:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1669289952; bh=8z9Pg26OhL7BSdfCL90aqbUPTDgCVV/fuwPpHgrpg+E=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=v26EcnEOifjV+S4TEUwiAFpdAEjixBaFKUPuoq67+8xryvz0mKe3qjUqMrWVtoKHh ksF9DdB0cyqolyEc1pNKvMOx7XVMlP8kN/hhFwlZI6JmNzeo5ZI8pY26lg+VV+Gkk9 szMdGoxm0y/0JS+YBJO6bbr6OdCO3w7EjVi+mlplmSA+HyU6qzkQRDYCKmDyiTKIlx dcM86XxAFvQqV2tFRWr99u2Gc3KOf1Y8nbxhX6h1QLLHkQ5q7Ri2Oc7s0pfO1HJzPe RC5VUJrLjv3IMYRuM41ydLH/fFdp7BUgB9WhNS1/VFTSrDc5nIjj+Z6octx72D+qk0 UD3Ou6GBIAeAw== 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 F36A96331C for ; Thu, 24 Nov 2022 12:39:09 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="RVa8IHwl"; dkim-atps=neutral Received: from pyrite.tail37cf.ts.net (h175-177-042-159.catv02.itscom.jp [175.177.42.159]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C6EAA496; Thu, 24 Nov 2022 12:39:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1669289949; bh=8z9Pg26OhL7BSdfCL90aqbUPTDgCVV/fuwPpHgrpg+E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RVa8IHwlGjOlDAFFKmcvegF1PJNOvyH7rxGZ6TmECPrXwLk/7bHDd78xeBsmaEJ6o leq7tBo5dr/w54L7Ty/e0kNzeaJw5TMYGPMYOxvfXwL6zvhCx4FsoHR7tpmFHX1lgy RtzeMthtANWh55A/Ly/NC08F/t0GPgGxVQ9ucMVc= To: libcamera-devel@lists.libcamera.org Date: Thu, 24 Nov 2022 20:38:49 +0900 Message-Id: <20221124113849.2193579-7-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221124113849.2193579-1-paul.elder@ideasonboard.com> References: <20221124113849.2193579-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 6/6] utils: libtuning: Get debug parameters from cli arguments 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: Paul Elder via libcamera-devel From: Paul Elder Reply-To: Paul Elder Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Get the debug parameters for enabling per-module debug from command line arguments. Signed-off-by: Paul Elder --- utils/tuning/libtuning/libtuning.py | 40 ++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/utils/tuning/libtuning/libtuning.py b/utils/tuning/libtuning/libtuning.py index 469e6940..6d616ddb 100644 --- a/utils/tuning/libtuning/libtuning.py +++ b/utils/tuning/libtuning/libtuning.py @@ -5,6 +5,7 @@ # libtuning.py - An infrastructure for camera tuning tools import argparse +from pathlib import Path import libtuning as lt import libtuning.utils as utils @@ -20,10 +21,6 @@ class Color(IntEnum): B = 3 -class Debug(Enum): - Plot = 1 - - # @brief What to do with the leftover pixels after dividing them into ALSC # sectors, when the division gradient is uniform # @var Float Force floating point division so all sectors divide equally @@ -157,6 +154,23 @@ class Tuner(object): # we want a better logging infrastructure with log levels parser.add_argument('-l', '--log', type=str, default=None, help='Output log file (optional)') + parser.add_argument('-dd', '--debug_dir', type=str, default=None, + help='''Debug output directory (optional). + If the directory does not exist, it will be + created (including parent directories). If + the directory already exists, any existing + contents will be overwritten.''') + module_list = [module.type for module in self.modules] + module_list.append('macbeth') + module_list.sort() + parser.add_argument('-do', '--debug_opt', type=str, default='', + help=f'''Debug option string (optional). + Comma-separated (without spaces) list of module names + for which debug output should be enabled. If this + option is not provided but --debug_dir is, then all + modules will have debug output enabled. This option + will not do anything if --debug_dir is not specified. + Available modules: {module_list}''') return parser.parse_args(argv[1:]) def run(self, argv): @@ -181,11 +195,29 @@ class Tuner(object): if module in self.modules: self.modules.remove(module) + # Prepare debug + module_debug_list = args.debug_opt.split(',') + if '' in module_debug_list: + module_debug_list.remove('') + + if args.debug_dir is not None: + debug_dir = Path(args.debug_dir) + if not debug_dir.is_dir(): + debug_dir.mkdir() + + # Validate modules and set debug for module in self.modules: if not module.validate_config(self.config): eprint(f'Config is invalid for module {module.type}') return -1 + if args.debug_dir is not None and \ + (len(module_debug_list) == 0 or module.type in module_debug_list): + module_debug_dir = debug_dir / module.type + if not module_debug_dir.is_dir(): + module_debug_dir.mkdir() + module.enable_debug(module_debug_dir) + has_lsc = any(isinstance(m, lt.modules.lsc.LSC) for m in self.modules) # Only one LSC module allowed has_only_lsc = has_lsc and len(self.modules) == 1