[{"id":23874,"web_url":"https://patchwork.libcamera.org/comment/23874/","msgid":"<YtAf9a/Yvl/+PjJ9@pendragon.ideasonboard.com>","date":"2022-07-14T13:53:57","subject":"Re: [libcamera-devel] [PATCH v2 1/2] utils: raspberrypi: ctt: Add\n\talsc_only method","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi William,\n\nThank you for the patch.\n\nOn Mon, Jul 11, 2022 at 11:26:27AM +0100, william.vinnicombe--- via libcamera-devel wrote:\n> From: William Vinnicombe <william.vinnicombe@raspberrypi.com>\n> \n> The ctt would not work if only passed alsc images.\n> \n> Add alsc_only.py to run alsc calibration only, and modify check_imgs\n> to allow for no macbeth chart images.\n> \n> Example usage would be ./alsc_only.py -i tuning-images/ -o sensor.json\n> with the same optional arguments as the original ctt.\n> \n> Signed-off-by: William Vinnicombe <william.vinnicombe@raspberrypi.com>\n> Reviewed-by: David Plowman <david.plowman@raspberrypi.com>\n> Reviewed-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\n> \n> diff --git a/utils/raspberrypi/ctt/alsc_only.py b/utils/raspberrypi/ctt/alsc_only.py\n> new file mode 100755\n> index 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)\n\nThat's much better than v1, thanks.\n\nMaybe it's a stupid question, but given that the only difference between\nthis and the main function of ctt.py is the alsc_only parameter passed\nto run_ctt(), could we go one step further and add an optional command\nline argument to select the ALSC-only mode, and avoid adding a separate\ntool ?\n\nThe rest looks fine.\n\n> diff --git a/utils/raspberrypi/ctt/ctt.py b/utils/raspberrypi/ctt/ctt.py\n> index 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)","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 6C1E5BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 14 Jul 2022 13:54:31 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AF0B163312;\n\tThu, 14 Jul 2022 15:54:30 +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 E22B16330D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 14 Jul 2022 15:54:28 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 55D0F45F;\n\tThu, 14 Jul 2022 15:54:28 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1657806870;\n\tbh=6e3/PYhGb5ySzmGzVO9/FCFusNQ7rYAea8z+V615ZrQ=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=1IwfTPVn9o3tbOxABNGaiP82OlvKTkmtBMhS4zc+X58RuUi+E6VgCor7RI3G/4Shv\n\te7RXRPPpgJGnlebSr1u8UMq+xFhf1j3ouqa7brUhijEVUC1t5Ac5AVjy0xFfQjeRvs\n\tIztfdMUFlMDQPu9+WTAB11qwbH7GnRs7QsOocTsEI7vdAvZYJzkvRoeXmsB11Rvrcr\n\t+k+nma0FHD8Eudg8t+r1ASTI4ooYjqIVwKd54aKMbM+HsQJhk0uokTZYzzOGYupQFJ\n\tJVUjIUMgTWoQXuFRAF3Fru11eiACoQjbSn1GskGkqMWXiECsPePJG+APtjEoge/sqG\n\tDXd3q1uwk6FXA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1657806868;\n\tbh=6e3/PYhGb5ySzmGzVO9/FCFusNQ7rYAea8z+V615ZrQ=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=nnAJnGXpEcBmjH045tEyKuxt1drANRyVgYUDhf3nagbQWydf7uE6KeujtPt/h+nA4\n\ts3p45yD6FvBrloPlsA8jn23wz+YkuQpbrDBVA8YVEw0nb3+Ut59IBF2hNkmhMlxzQD\n\tLEt7LCRlt5ez4YztueAmYC1+p13z5MhTK/sG/aus="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"nnAJnGXp\"; dkim-atps=neutral","Date":"Thu, 14 Jul 2022 16:53:57 +0300","To":"william.vinnicombe@raspberrypi.com","Message-ID":"<YtAf9a/Yvl/+PjJ9@pendragon.ideasonboard.com>","References":"<20220711102628.14269-1-william.vinnicombe@raspberrypi.com>\n\t<20220711102628.14269-2-william.vinnicombe@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220711102628.14269-2-william.vinnicombe@raspberrypi.com>","Subject":"Re: [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":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":23936,"web_url":"https://patchwork.libcamera.org/comment/23936/","msgid":"<CAA9M1nXvM7-iaZVQsqS7Kv29mESgWSCTR4wceNLOXicVh28JWA@mail.gmail.com>","date":"2022-07-15T14:22:44","subject":"Re: [libcamera-devel] [PATCH v2 1/2] utils: raspberrypi: ctt: Add\n\talsc_only method","submitter":{"id":131,"url":"https://patchwork.libcamera.org/api/people/131/","name":"William Vinnicombe","email":"william.vinnicombe@raspberrypi.com"},"content":"Hi Laurent,\n\nThanks for your comments.\n\nI think we were hoping to make it a separate file, so it's easier for users\nto run\nonly the lens shading, as that's the aspect of the tool we expect to be\nused more\ngiven users will want to use different lenses.\n\nBest,\n\nWilliam Vinnicombe\n\nOn Thu, 14 Jul 2022 at 14:54, Laurent Pinchart <\nlaurent.pinchart@ideasonboard.com> wrote:\n\n> Hi William,\n>\n> Thank you for the patch.\n>\n> On Mon, Jul 11, 2022 at 11:26:27AM +0100, william.vinnicombe--- via\n> libcamera-devel wrote:\n> > From: William Vinnicombe <william.vinnicombe@raspberrypi.com>\n> >\n> > The ctt would not work if only passed alsc images.\n> >\n> > Add alsc_only.py to run alsc calibration only, and modify check_imgs\n> > to allow for no macbeth chart images.\n> >\n> > Example usage would be ./alsc_only.py -i tuning-images/ -o sensor.json\n> > with the same optional arguments as the original ctt.\n> >\n> > Signed-off-by: William Vinnicombe <william.vinnicombe@raspberrypi.com>\n> > Reviewed-by: David Plowman <david.plowman@raspberrypi.com>\n> > Reviewed-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\n> >\n> > diff --git a/utils/raspberrypi/ctt/alsc_only.py\n> b/utils/raspberrypi/ctt/alsc_only.py\n> > new file mode 100755\n> > index 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\n> 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,\n> alsc_only=True)\n>\n> That's much better than v1, thanks.\n>\n> Maybe it's a stupid question, but given that the only difference between\n> this and the main function of ctt.py is the alsc_only parameter passed\n> to run_ctt(), could we go one step further and add an optional command\n> line argument to select the ALSC-only mode, and avoid adding a separate\n> tool ?\n>\n> The rest looks fine.\n>\n> > diff --git a/utils/raspberrypi/ctt/ctt.py b/utils/raspberrypi/ctt/ctt.py\n> > index 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,\n> alsc_only=False):\n> >      \"\"\"\n> >      check input files are jsons\n> >      \"\"\"\n> > @@ -766,6 +770,8 @@ def run_ctt(json_output, directory, config,\n> 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 =\n> 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,\n> log_output):\n> >      ccm also technically does an awb but it measures this from the\n> 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'] =\n> Cam.blacklevel_16\n> >          Cam.json_remove(disable)\n> >          print('\\nSTARTING CALIBRATIONS')\n> >          Cam.alsc_cal(luminance_strength, do_alsc_colour)\n>\n> --\n> Regards,\n>\n> Laurent Pinchart\n>","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 7A99DBD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 15 Jul 2022 14:22:59 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E49D963312;\n\tFri, 15 Jul 2022 16:22:58 +0200 (CEST)","from mail-qk1-x733.google.com (mail-qk1-x733.google.com\n\t[IPv6:2607:f8b0:4864:20::733])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D8C3E6330A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 15 Jul 2022 16:22:57 +0200 (CEST)","by mail-qk1-x733.google.com with SMTP id q9so1098122qkc.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 15 Jul 2022 07:22:57 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1657894978;\n\tbh=ZPLxT81EWmLXs8TQP5/JOpcOlnFkrGqCn8c0zUCIgZs=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=AKjgoKyHVj/Hh6hWnRpkNmN/KIpEp9nEWtnGe3jueMJ65deGI85aTSTDKqyxMmbvo\n\t2VPMzF0WAkjqKbDrYe5Gwfm9yFzysrG+2MMRWDBHx5m964QDJclB4v6Gt84eOw15VB\n\twlbQt+/ojTDwfVhlVesHjNsPfjBHy5MkNZ/cS/VfWo0ooGdmW57FSiCAy+6Idinbl/\n\t549NO8B4aLZ07Yw9tljkaXsP+hHMDe2AF2Uwv+ZoLx7PA2QfLguy+32vzrmvFlevge\n\t8PngvQ1vARtxhNSwn7jO4+QtIXgoUAnNYkH8+xfwFaw462nWsfUaqnEPi1yKRppZl8\n\tnynSeVl70HCGA==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=eSEKf0lU6cIDr9GlaNqC6I6tQ2tnhrxgbrOWYufjBGs=;\n\tb=Ii38z1wSj+YKzgGs/nl6AqSjYSUOz5Mtu9AE/KBO6rbcLCjFyqwvZorIUaMNuRCf11\n\tVXG3detCIbp0sqTOZFRmpZTCkg15vf78R3V8jJKXo7Cot/MA/aGtBc8PMgynEzi5Zwyu\n\tc4dJlNRSSA2GcDlo0Th3nWp9LjqQyi0xy53kiheMl1bfwa6+Ka34UBrBWpaEFgBJf3j2\n\twhJULFDXTEFpanNkcjlsThpTd5KLzj4PP0EQOen2lcGps0zoaVGXCev/f0pE9xkyw4lK\n\t4l4MLVdtYBYKpMb1MVAozc/qFlSPBkMI3qfjqJMAuozIRQ7MLKRpM3doYGKo2n8/qWlj\n\t5P8A=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"Ii38z1wS\"; 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:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=eSEKf0lU6cIDr9GlaNqC6I6tQ2tnhrxgbrOWYufjBGs=;\n\tb=BrWQVK+rTDxltkxi1xESjAxjlQpYF7cXm/T0IyDDh6kBAgq1OGG1uALWk+gnXe2vNw\n\tjHy6lABj3fsbWkL8nOf7JiUYtK8RXAZxSlZunIZ2Zz9TzGkwL7DQWY2IzNsDED5hwjtT\n\tcwyllNfYMIMEl/e/bFfF2DolCec4ejuHI9z5kMjWlmcBv02i9uRsHg//OcbuQXC13O66\n\tW4/xj6HKeUbd3wk8tDlI7/sGNGbU7zZAgmf04VbkHlAuNHx/+dRK3MEbSxQ8Y0ChRkHF\n\teMUDqvncArDEHvXaFkS7OkUcEpid8JGBeNKJC2Tof44yqQX6v0LkmUQXh+ePB8Ac2SQC\n\t9TWw==","X-Gm-Message-State":"AJIora864fSEBK1xGzygu4/AJvCNUGbBhoZCYD36ThGakmVJvOkatgTE\n\tLVDIGFuYIl3WI8o/CyCxoMMSl8O5Omr3HTiI2tDQk2DbyIs=","X-Google-Smtp-Source":"AGRyM1vS3n8lZMrBUu2pM4B2A1mQ5gQgShE6ND0srbthUWIzySiUJGKYaGBczYl2pCmSrbkfY6VHKisf/rc2DLhvyZk=","X-Received":"by 2002:a05:620a:2a0e:b0:6b4:68a0:39fe with SMTP id\n\to14-20020a05620a2a0e00b006b468a039femr9563667qkp.3.1657894976588;\n\tFri, 15 Jul 2022 07:22:56 -0700 (PDT)","MIME-Version":"1.0","References":"<20220711102628.14269-1-william.vinnicombe@raspberrypi.com>\n\t<20220711102628.14269-2-william.vinnicombe@raspberrypi.com>\n\t<YtAf9a/Yvl/+PjJ9@pendragon.ideasonboard.com>","In-Reply-To":"<YtAf9a/Yvl/+PjJ9@pendragon.ideasonboard.com>","Date":"Fri, 15 Jul 2022 15:22:44 +0100","Message-ID":"<CAA9M1nXvM7-iaZVQsqS7Kv29mESgWSCTR4wceNLOXicVh28JWA@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Content-Type":"multipart/alternative; boundary=\"00000000000027a15305e3d8c132\"","Subject":"Re: [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 <william.vinnicombe@raspberrypi.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":24310,"web_url":"https://patchwork.libcamera.org/comment/24310/","msgid":"<YuktegvStffO9Q1k@pendragon.ideasonboard.com>","date":"2022-08-02T13:58:18","subject":"Re: [libcamera-devel] [PATCH v2 1/2] utils: raspberrypi: ctt: Add\n\talsc_only method","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi William,\n\nOn Fri, Jul 15, 2022 at 03:22:44PM +0100, William Vinnicombe wrote:\n> Hi Laurent,\n> \n> Thanks for your comments.\n> \n> I think we were hoping to make it a separate file, so it's easier for users to run\n> only the lens shading, as that's the aspect of the tool we expect to be used more\n> given users will want to use different lenses.\n\nFair enough.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> On Thu, 14 Jul 2022 at 14:54, Laurent Pinchart wrote:\n> > On Mon, Jul 11, 2022 at 11:26:27AM +0100, william.vinnicombe--- via libcamera-devel wrote:\n> > > From: William Vinnicombe <william.vinnicombe@raspberrypi.com>\n> > >\n> > > The ctt would not work if only passed alsc images.\n> > >\n> > > Add alsc_only.py to run alsc calibration only, and modify check_imgs\n> > > to allow for no macbeth chart images.\n> > >\n> > > Example usage would be ./alsc_only.py -i tuning-images/ -o sensor.json\n> > > with the same optional arguments as the original ctt.\n> > >\n> > > Signed-off-by: William Vinnicombe <william.vinnicombe@raspberrypi.com>\n> > > Reviewed-by: David Plowman <david.plowman@raspberrypi.com>\n> > > Reviewed-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\n> > >\n> > > diff --git a/utils/raspberrypi/ctt/alsc_only.py b/utils/raspberrypi/ctt/alsc_only.py\n> > > new file mode 100755\n> > > index 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)\n> >\n> > That's much better than v1, thanks.\n> >\n> > Maybe it's a stupid question, but given that the only difference between\n> > this and the main function of ctt.py is the alsc_only parameter passed\n> > to run_ctt(), could we go one step further and add an optional command\n> > line argument to select the ALSC-only mode, and avoid adding a separate\n> > tool ?\n> >\n> > The rest looks fine.\n> >\n> > > diff --git a/utils/raspberrypi/ctt/ctt.py b/utils/raspberrypi/ctt/ctt.py\n> > > index 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)","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 B91C5BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  2 Aug 2022 13:58:26 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E0D8063313;\n\tTue,  2 Aug 2022 15:58:25 +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 1E57A603E7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  2 Aug 2022 15:58:24 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8934425B;\n\tTue,  2 Aug 2022 15:58:23 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1659448706;\n\tbh=iekp8Tj1QLsI+WkEDVq1vDqlqaHCP8h9w2pXuX9686U=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=4RhEc4Ke4sMcE01oXGIaJA1fIjXKZdFFSyKiWeAptbIJ9SrbrQVCseHW4v+UBfCJ6\n\tmCrPa++UAbQxiR3rsL1xWm4MfXwYRcsc7LH8EWbjLtthfXxCuKQ6Kxpr8/6UXCK5Ro\n\tVbpLm2Yv/jF/tbLBsrygp4SjfVj3X0xpf1UY04HbV9j/CjLE4yZjJIjbY0IROb3y7U\n\t00Ei1ze+85vO1lfNJlUz5HPLRpDt6XxBaxhna9UdroMkfuOjrCQ6NVvdC3tNznFRRl\n\t5CX0qwtYaM6oK4Umf5A7ge3O0mcn1M3sRhbgNuEHpxCpi5mfMYnXB5Q/oq9h0z4fv/\n\t+sNycqrom7Lbg==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1659448703;\n\tbh=iekp8Tj1QLsI+WkEDVq1vDqlqaHCP8h9w2pXuX9686U=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=tEDIDSkgPRce4zVsC+PFBl0GF7bu1PZC0S8MD17Uc1NP9dMuLEYAwxXljNbCZFY1K\n\tY+dxJBZXfAT7YcLcQM87pRhFza11vNAF/xBrb6eeXnxjuRrcZ2thlTUMJ+Pm0Z56LC\n\t7yEwPyhJ1LlcRL7Uu21epUBmxgywiA9J2kwQksrM="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"tEDIDSkg\"; dkim-atps=neutral","Date":"Tue, 2 Aug 2022 16:58:18 +0300","To":"William Vinnicombe <william.vinnicombe@raspberrypi.com>","Message-ID":"<YuktegvStffO9Q1k@pendragon.ideasonboard.com>","References":"<20220711102628.14269-1-william.vinnicombe@raspberrypi.com>\n\t<20220711102628.14269-2-william.vinnicombe@raspberrypi.com>\n\t<YtAf9a/Yvl/+PjJ9@pendragon.ideasonboard.com>\n\t<CAA9M1nXvM7-iaZVQsqS7Kv29mESgWSCTR4wceNLOXicVh28JWA@mail.gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<CAA9M1nXvM7-iaZVQsqS7Kv29mESgWSCTR4wceNLOXicVh28JWA@mail.gmail.com>","Subject":"Re: [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":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]