{"id":20523,"url":"https://patchwork.libcamera.org/api/patches/20523/?format=json","web_url":"https://patchwork.libcamera.org/patch/20523/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20240703141726.252368-10-stefan.klug@ideasonboard.com>","date":"2024-07-03T14:16:58","name":"[v3,09/23] libtuning: Improve filename parsing","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"b1c73dfc61072b09182a27f400b910ab9f30540c","submitter":{"id":184,"url":"https://patchwork.libcamera.org/api/people/184/?format=json","name":"Stefan Klug","email":"stefan.klug@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/20523/mbox/","series":[{"id":4437,"url":"https://patchwork.libcamera.org/api/series/4437/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4437","date":"2024-07-03T14:16:49","name":"Add ccm calibration to libtuning","version":3,"mbox":"https://patchwork.libcamera.org/series/4437/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/20523/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/20523/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 60D2CBEFBE\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  3 Jul 2024 14:18:02 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EF38763352;\n\tWed,  3 Jul 2024 16:18:01 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 59DCE63362\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  3 Jul 2024 16:17:59 +0200 (CEST)","from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:9263:c199:9587:576])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 33A994CA;\n\tWed,  3 Jul 2024 16:17:31 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"H47AgwEv\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1720016251;\n\tbh=YivJPVzYaTF92WKi8YwCCPOvj6rqc8S0NZ+QdhsD7J8=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=H47AgwEv412/6fXxcUzwNFWL1lzw4dh5mfdaHQFsHRK+8zSp8I7Q1ESy99oPQEElI\n\tGPzbW9h8F0FhLeDL3ZYPjSb5pC6Nq8qm2/PlPHvpLYKGobtNzSYwtrj2WDIV9pwru4\n\tkEZSZt/X0nj1chH2JjGekBeXiRjwN0Eo/sSL9aeI=","From":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tPaul Elder <paul.elder@ideasonboard.com>","Subject":"[PATCH v3 09/23] libtuning: Improve filename parsing","Date":"Wed,  3 Jul 2024 16:16:58 +0200","Message-ID":"<20240703141726.252368-10-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","Content-Transfer-Encoding":"8bit","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"In the tuning datasets, the files had names like\n'imx335_1600l_3000k_1.dng'. That failed on the old filename parsing\nfunction. As there is no need to dictate the order of the tags, split\nthe big regex into chunks and parse them one by one. This also makes\nthe code easier to digest.\n\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n---\n utils/tuning/libtuning/utils.py | 30 ++++++++++++++++++++++--------\n 1 file changed, 22 insertions(+), 8 deletions(-)","diff":"diff --git a/utils/tuning/libtuning/utils.py b/utils/tuning/libtuning/utils.py\nindex 90fd7072a0fd..c70dfae049bc 100644\n--- a/utils/tuning/libtuning/utils.py\n+++ b/utils/tuning/libtuning/utils.py\n@@ -43,16 +43,30 @@ def _list_image_files(directory):\n \n \n def _parse_image_filename(fn: Path):\n-    result = re.search(r'^(alsc_)?(\\d+)[kK]_(\\d+)?[lLuU]?.\\w{3,4}$', fn.name)\n-    if result is None:\n-        logger.error(f'The file name of {fn.name} is incorrectly formatted')\n-        return None, None, None\n+    lsc_only = False\n+    color_temperature = None\n+    lux = None\n+\n+    parts = fn.stem.split('_')\n+    for part in parts:\n+        if part == 'alsc':\n+            lsc_only = True\n+            continue\n+        r = re.match(r'(\\d+)[kK]', part)\n+        if r:\n+            color_temperature = int(r.group(1))\n+            continue\n+        r = re.match(r'(\\d+)[lLuU]', part)\n+        if r:\n+            lux = int(r.group(1))\n+\n+    if color_temperature is None:\n+        logger.error(f'The file name of \"{fn.name}\" does not contain a color temperature')\n \n-    color = int(result.group(2))\n-    lsc_only = result.group(1) is not None\n-    lux = None if lsc_only else int(result.group(3))\n+    if lux is None and lsc_only is False:\n+        logger.error(f'The file name of \"{fn.name}\" must either contain alsc or a lux level')\n \n-    return color, lux, lsc_only\n+    return color_temperature, lux, lsc_only\n \n \n # \\todo Implement this from check_imgs() in ctt.py\n","prefixes":["v3","09/23"]}