From patchwork Wed Jul 3 14:17:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 20525 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 A1709BEFBE for ; Wed, 3 Jul 2024 14:18:08 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5901763363; Wed, 3 Jul 2024 16:18:08 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="i2W1EZPQ"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2445F63365 for ; Wed, 3 Jul 2024 16:18:05 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:9263:c199:9587:576]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0532F4CA; Wed, 3 Jul 2024 16:17:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1720016257; bh=WDvuEgRZJSn8ft56e1J+vD0dxPn56D/Aap9b1kKGZWM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i2W1EZPQfW8OFdxnwJvlHebWeQ7Gno/i8CX1HYnUTGTgj3qcE8J2LlWVKmt1tkP1b fDACb0Ycq4aB6PI+2s00gDBBzebJy1w3ObUSNq9lUe51xijmHMO34ZOEED/lX0L58B JDlAxiQQao0cXk7JdcdLif24VSGQfoWWDQ7frDis= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v3 11/23] libtuning: Reactivate macbeth locator Date: Wed, 3 Jul 2024 16:17:00 +0200 Message-ID: <20240703141726.252368-12-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240703141726.252368-1-stefan.klug@ideasonboard.com> References: <20240703141726.252368-1-stefan.klug@ideasonboard.com> 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" Add the missing pieces and store the result inside the image object. Signed-off-by: Stefan Klug Reviewed-by: Paul Elder --- utils/tuning/libtuning/image.py | 1 + utils/tuning/libtuning/macbeth.py | 13 ++++++++++--- utils/tuning/libtuning/utils.py | 4 ++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/utils/tuning/libtuning/image.py b/utils/tuning/libtuning/image.py index 2c4d774f11e2..c8911a0ff125 100644 --- a/utils/tuning/libtuning/image.py +++ b/utils/tuning/libtuning/image.py @@ -24,6 +24,7 @@ class Image: self.lsc_only = False self.color = -1 self.lux = -1 + self.macbeth = None try: self._load_metadata_exif() diff --git a/utils/tuning/libtuning/macbeth.py b/utils/tuning/libtuning/macbeth.py index 28051de8155c..4a2006b013dc 100644 --- a/utils/tuning/libtuning/macbeth.py +++ b/utils/tuning/libtuning/macbeth.py @@ -17,12 +17,15 @@ import logging from sklearn import cluster as cluster from .ctt_ransac import get_square_verts, get_square_centres - -from libtuning.image import Image +from .image import Image logger = logging.getLogger(__name__) +class MacbethError(Exception): + pass + + # Reshape image to fixed width without distorting returns image and scale # factor def reshape(img, width): @@ -377,7 +380,9 @@ def get_macbeth_chart(img, ref_data): # Catch macbeth errors and continue with code except MacbethError as error: - logger.warning(error) + # \todo: This happens so many times in a normal run, that it shadows + # all the relevant output + # logger.warning(error) return (0, None, None, False) @@ -527,4 +532,6 @@ def locate_macbeth(image: Image, config: dict): logger.warning(f'Macbeth patches have saturated in {image.path.name}') return None + image.macbeth = macbeth + return macbeth diff --git a/utils/tuning/libtuning/utils.py b/utils/tuning/libtuning/utils.py index c70dfae049bc..93c6c94ea2b0 100644 --- a/utils/tuning/libtuning/utils.py +++ b/utils/tuning/libtuning/utils.py @@ -17,7 +17,7 @@ import logging import libtuning as lt from libtuning.image import Image -from libtuning.macbeth import locate_macbeth +from .macbeth import locate_macbeth logger = logging.getLogger(__name__) @@ -127,7 +127,7 @@ def load_images(input_dir: str, config: dict, load_nonlsc: bool, load_lsc: bool) continue # Handle macbeth - macbeth = locate_macbeth(config) + macbeth = locate_macbeth(image, config) if macbeth is None: continue