{"id":16582,"url":"https://patchwork.libcamera.org/api/1.1/patches/16582/?format=json","web_url":"https://patchwork.libcamera.org/patch/16582/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20220711102628.14269-2-william.vinnicombe@raspberrypi.com>","date":"2022-07-11T10:26:27","name":"[libcamera-devel,v2,1/2] utils: raspberrypi: ctt: Add alsc_only method","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"bee0d535d6b0c17c20a9f1cbb76f22d8669d4e34","submitter":{"id":97,"url":"https://patchwork.libcamera.org/api/1.1/people/97/?format=json","name":"Nicolas Dufresne via libcamera-devel","email":"libcamera-devel@lists.libcamera.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/16582/mbox/","series":[{"id":3268,"url":"https://patchwork.libcamera.org/api/1.1/series/3268/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3268","date":"2022-07-11T10:26:26","name":"Raspberry Pi tuning tool improvements","version":2,"mbox":"https://patchwork.libcamera.org/series/3268/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/16582/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/16582/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 EC71FBD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 11 Jul 2022 10:31:31 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B49F360401;\n\tMon, 11 Jul 2022 12:31:30 +0200 (CEST)","from mail-wm1-x333.google.com (mail-wm1-x333.google.com\n\t[IPv6:2a00:1450:4864:20::333])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4549360401\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 11 Jul 2022 12:26:41 +0200 (CEST)","by mail-wm1-x333.google.com with SMTP id\n\t9-20020a1c0209000000b003a2dfdebe47so1940839wmc.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 11 Jul 2022 03:26:41 -0700 (PDT)","from wv-laptop.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tp12-20020a7bcc8c000000b0039749b01ea7sm8138000wma.32.2022.07.11.03.26.40\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 11 Jul 2022 03:26:40 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1657535490;\n\tbh=leIqYoa7gmb22d7dQVKCR5dxstWMme/vYijcJBtGy70=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=RI96ERjwO0fbEHMzj8CSPECVWLH3x2CqRbQjTwksn31ixm/KPdVGPKTEU0diCntYu\n\t78U6RlHfE+XX6YZLAjXPa1VP6ZgIrjcGgYppGKYRzDR3VmgpsdzCBkylTZiZcKXnjn\n\tIsyZK76gUQnW2AHpQL0s9MdBoY0XjqQZOamfVn2FE2Fv6XEPwPzD/lCrQOJRq3r97Z\n\tmb913dorIgPeQ1H6kJ8kBRIlrioS10rexnpjB+vdwRNpkEquZHNhtOUsTfl1zuczxO\n\tk2B1bwiWf2FxeQRNfE1nRgGlwsIG5ep9G/gOZW0fhc+Jk1sV3GWaNwtltUBJSY+Ycb\n\t4C/QC0jjYYltQ==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=hgBecB6GsSuUNGJ7Z6PxPun09afqeP2+nSpFxwdEzZs=;\n\tb=AkNIdUR6FiympdjhvCvz9ghq3IfyX3quohLRyU+Cl1/ql9rws/akVBpVginlKjQ6Ec\n\tlC4KKIsS5N2VD6ItsR7d+IYpzxgJ8NaK6DPinTN1edJNLHoFVe+rehjev9rxkaysbmwg\n\twxSalR5lyswhb46Ly9Ebe47YxG33trCc9ndda4kaei6ghYrEyY9DHUGTE24hd3hoZbaU\n\tnEr37rvEn35XnUHXr6kI497V6xThc36nmjogdAoIAFAB+nqEZT0BK1pEuEoSryY+jxn3\n\tedGMG2Zi+wTOeDlGYEb8HCaZSmIghKvliVd4RBIY0bDdzemVh49000fqvUMAvKUqiFoT\n\tkZOQ=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"AkNIdUR6\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=hgBecB6GsSuUNGJ7Z6PxPun09afqeP2+nSpFxwdEzZs=;\n\tb=jQt4qKgdMHe2MZRr2QKq+Ih/y8XmXCFS5o4pXWGRlurgW4G/CdSO9F2hA9sIO3oE3d\n\tQo5C7yrua2ZhtE2Mqhor4Aj2I5CDeBj3iZUhZy6/CCFwm0pRo+R+FZ9tuIo83uCLJ+Ba\n\tkCNHQQr6gixpBz3+WU9Q3g3GQEt1l2G6G2MZX/aBxukME44b7+v3If7qIaWooqmFJFDO\n\tnGnmUc8H0O29XK1EmuDFEqKKCxxVFNIFZv7FqmtygaH/0oMhe17t0UAWBqM2BfdO6sXq\n\t/7HplMyUadJXXxh6SYCqsHxCCuCRwY7yQM/7ZshhtleJPkMO0OCooEgf39Oj5gjCttne\n\tU/ow==","X-Gm-Message-State":"AJIora9JGUtU16PHbJ+MUkIxK80/SxctWrmz7zt44T5TaShrTfQIKJau\n\t66GZ7YuberryHjRgNwSqqTt0EJkG8b4prg==","X-Google-Smtp-Source":"AGRyM1so0hFdvUgoMiL0gROo6vlRInLq6RaP19BCOM406+BrYrwjDj39M4p+sRW3z4753njOrVND8g==","X-Received":"by 2002:a05:600c:154c:b0:3a1:884e:72ac with SMTP id\n\tf12-20020a05600c154c00b003a1884e72acmr15777210wmg.23.1657535200613; \n\tMon, 11 Jul 2022 03:26:40 -0700 (PDT)","To":"libcamera-devel@lists.libcamera.org","Date":"Mon, 11 Jul 2022 11:26:27 +0100","Message-Id":"<20220711102628.14269-2-william.vinnicombe@raspberrypi.com>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<20220711102628.14269-1-william.vinnicombe@raspberrypi.com>","References":"<20220711102628.14269-1-william.vinnicombe@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-Mailman-Approved-At":"Mon, 11 Jul 2022 12:31:27 +0200","Subject":"[libcamera-devel] [PATCH v2 1/2] utils: raspberrypi: ctt: Add\n\talsc_only method","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>","From":"\"william.vinnicombe--- via libcamera-devel\"\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"william.vinnicombe@raspberrypi.com","Cc":"William Vinnicombe <william.vinnicombe@raspberrypi.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"From: William Vinnicombe <william.vinnicombe@raspberrypi.com>\n\nThe ctt would not work if only passed alsc images.\n\nAdd alsc_only.py to run alsc calibration only, and modify check_imgs\nto allow for no macbeth chart images.\n\nExample usage would be ./alsc_only.py -i tuning-images/ -o sensor.json\nwith the same optional arguments as the original ctt.\n\nSigned-off-by: William Vinnicombe <william.vinnicombe@raspberrypi.com>\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\nReviewed-by: Naushir Patuck <naush@raspberrypi.com>\n---\n utils/raspberrypi/ctt/alsc_only.py | 34 ++++++++++++++++++++++++++++++\n utils/raspberrypi/ctt/ctt.py       | 17 ++++++++++-----\n 2 files changed, 46 insertions(+), 5 deletions(-)\n create mode 100755 utils/raspberrypi/ctt/alsc_only.py","diff":"diff --git a/utils/raspberrypi/ctt/alsc_only.py b/utils/raspberrypi/ctt/alsc_only.py\nnew file mode 100755\nindex 00000000..7cd0ac01\n--- /dev/null\n+++ b/utils/raspberrypi/ctt/alsc_only.py\n@@ -0,0 +1,34 @@\n+#!/usr/bin/env python3\n+#\n+# SPDX-License-Identifier: BSD-2-Clause\n+#\n+# Copyright (C) 2022, Raspberry Pi (Trading) Limited\n+#\n+# alsc_only.py - alsc tuning tool\n+\n+from ctt import *\n+\n+\n+if __name__ == '__main__':\n+    \"\"\"\n+    initialise calibration\n+    \"\"\"\n+    if len(sys.argv) == 1:\n+        print(\"\"\"\n+    Pisp Camera Tuning Tool version 1.0\n+\n+    Required Arguments:\n+    '-i' : Calibration image directory.\n+    '-o' : Name of output json file.\n+\n+    Optional Arguments:\n+    '-c' : Config file for the CTT. If not passed, default parameters used.\n+    '-l' : Name of output log file. If not passed, 'ctt_log.txt' used.\n+              \"\"\")\n+        quit(0)\n+    else:\n+        \"\"\"\n+        parse input arguments\n+        \"\"\"\n+        json_output, directory, config, log_output = parse_input()\n+        run_ctt(json_output, directory, config, log_output, alsc_only=True)\ndiff --git a/utils/raspberrypi/ctt/ctt.py b/utils/raspberrypi/ctt/ctt.py\nindex 15064634..2bd97514 100755\n--- a/utils/raspberrypi/ctt/ctt.py\n+++ b/utils/raspberrypi/ctt/ctt.py\n@@ -664,7 +664,7 @@ class Camera:\n         - incorrect filename/extension\n         - images from different cameras\n     \"\"\"\n-    def check_imgs(self):\n+    def check_imgs(self, macbeth=True):\n         self.log += '\\n\\nImages found:'\n         self.log += '\\nMacbeth : {}'.format(len(self.imgs))\n         self.log += '\\nALSC : {} '.format(len(self.imgs_alsc))\n@@ -672,10 +672,14 @@ class Camera:\n         \"\"\"\n         check usable images found\n         \"\"\"\n-        if len(self.imgs) == 0:\n+        if len(self.imgs) == 0 and macbeth:\n             print('\\nERROR: No usable macbeth chart images found')\n             self.log += '\\nERROR: No usable macbeth chart images found'\n             return 0\n+        elif len(self.imgs) == 0 and len(self.imgs_alsc) == 0:\n+            print('\\nERROR: No usable images found')\n+            self.log += '\\nERROR: No usable images found'\n+            return 0\n         \"\"\"\n         Double check that every image has come from the same camera...\n         \"\"\"\n@@ -704,7 +708,7 @@ class Camera:\n             return 0\n \n \n-def run_ctt(json_output, directory, config, log_output):\n+def run_ctt(json_output, directory, config, log_output, alsc_only=False):\n     \"\"\"\n     check input files are jsons\n     \"\"\"\n@@ -766,6 +770,8 @@ def run_ctt(json_output, directory, config, log_output):\n     try:\n         Cam = Camera(json_output)\n         Cam.log_user_input(json_output, directory, config, log_output)\n+        if alsc_only:\n+            disable = set(Cam.json.keys()).symmetric_difference({\"rpi.alsc\"})\n         Cam.disable = disable\n         Cam.plot = plot\n         Cam.add_imgs(directory, mac_config, blacklevel)\n@@ -779,8 +785,9 @@ def run_ctt(json_output, directory, config, log_output):\n     ccm also technically does an awb but it measures this from the macbeth\n     chart in the image rather than using calibration data\n     \"\"\"\n-    if Cam.check_imgs():\n-        Cam.json['rpi.black_level']['black_level'] = Cam.blacklevel_16\n+    if Cam.check_imgs(macbeth=not alsc_only):\n+        if not alsc_only:\n+            Cam.json['rpi.black_level']['black_level'] = Cam.blacklevel_16\n         Cam.json_remove(disable)\n         print('\\nSTARTING CALIBRATIONS')\n         Cam.alsc_cal(luminance_strength, do_alsc_colour)\n","prefixes":["libcamera-devel","v2","1/2"]}