[{"id":30135,"web_url":"https://patchwork.libcamera.org/comment/30135/","msgid":"<20240628230946.GI30900@pendragon.ideasonboard.com>","date":"2024-06-28T23:09:46","subject":"Re: [PATCH v2 11/25] libtuning: Reactivate macbeth locator","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Stefan,\n\nThank you for the patch.\n\nOn Fri, Jun 28, 2024 at 12:47:04PM +0200, Stefan Klug wrote:\n> Add the missing pieces and store the result inside the image object.\n> \n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> ---\n>  utils/tuning/libtuning/image.py   |  1 +\n>  utils/tuning/libtuning/macbeth.py | 13 ++++++++++---\n>  utils/tuning/libtuning/utils.py   |  5 +++--\n>  3 files changed, 14 insertions(+), 5 deletions(-)\n> \n> diff --git a/utils/tuning/libtuning/image.py b/utils/tuning/libtuning/image.py\n> index 2c4d774f11e2..c8911a0ff125 100644\n> --- a/utils/tuning/libtuning/image.py\n> +++ b/utils/tuning/libtuning/image.py\n> @@ -24,6 +24,7 @@ class Image:\n>          self.lsc_only = False\n>          self.color = -1\n>          self.lux = -1\n> +        self.macbeth = None\n>  \n>          try:\n>              self._load_metadata_exif()\n> diff --git a/utils/tuning/libtuning/macbeth.py b/utils/tuning/libtuning/macbeth.py\n> index 28051de8155c..4a2006b013dc 100644\n> --- a/utils/tuning/libtuning/macbeth.py\n> +++ b/utils/tuning/libtuning/macbeth.py\n> @@ -17,12 +17,15 @@ import logging\n>  from sklearn import cluster as cluster\n>  \n>  from .ctt_ransac import get_square_verts, get_square_centres\n> -\n> -from libtuning.image import Image\n> +from .image import Image\n>  \n>  logger = logging.getLogger(__name__)\n>  \n>  \n> +class MacbethError(Exception):\n> +    pass\n> +\n> +\n>  # Reshape image to fixed width without distorting returns image and scale\n>  # factor\n>  def reshape(img, width):\n> @@ -377,7 +380,9 @@ def get_macbeth_chart(img, ref_data):\n>  \n>      # Catch macbeth errors and continue with code\n>      except MacbethError as error:\n> -        logger.warning(error)\n> +        # \\todo: This happens so many times in a normal run, that it shadows\n> +        # all the relevant output\n> +        # logger.warning(error)\n>          return (0, None, None, False)\n>  \n>  \n> @@ -527,4 +532,6 @@ def locate_macbeth(image: Image, config: dict):\n>          logger.warning(f'Macbeth patches have saturated in {image.path.name}')\n>          return None\n>  \n> +    image.macbeth = macbeth\n> +\n>      return macbeth\n> diff --git a/utils/tuning/libtuning/utils.py b/utils/tuning/libtuning/utils.py\n> index 00cf5a57512f..1e7991e84a70 100644\n> --- a/utils/tuning/libtuning/utils.py\n> +++ b/utils/tuning/libtuning/utils.py\n> @@ -17,7 +17,7 @@ import logging\n>  \n>  import libtuning as lt\n>  from libtuning.image import Image\n> -from libtuning.macbeth import locate_macbeth\n> +from .macbeth import locate_macbeth\n>  \n>  logger = logging.getLogger(__name__)\n>  \n> @@ -92,6 +92,7 @@ def load_images(input_dir: str, config: dict, load_nonlsc: bool, load_lsc: bool)\n>      images = []\n>      for f in files:\n>          color, lux, lsc_only = _parse_image_filename(f)\n> +        logger.info(f'Process image {f.name} (color={color}, lux={lux}, lsc_only={lsc_only})')\n\nShould this go after the color check ?\n\n>          if color is None:\n\nAnd should an error be reported here ?\n\nThis hunk seems to be a candidate for a separate patch.\n\n>              continue\n>  \n> @@ -127,7 +128,7 @@ def load_images(input_dir: str, config: dict, load_nonlsc: bool, load_lsc: bool)\n>              continue\n>  \n>          # Handle macbeth\n> -        macbeth = locate_macbeth(config)\n> +        macbeth = locate_macbeth(image, config)\n>          if macbeth is None:\n>              continue\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 21B83BD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 28 Jun 2024 23:10:09 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7719E62C9C;\n\tSat, 29 Jun 2024 01:10:08 +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 581EA62C97\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 29 Jun 2024 01:10:07 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 33C02471;\n\tSat, 29 Jun 2024 01:09:42 +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=\"VgbdjM7r\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1719616182;\n\tbh=XGT8jTc8gYyHooKAg3XLNHHRAilX2CgUrnqpkO72cGI=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=VgbdjM7r0mcwei4AYqpvlrRqpU4Y5zczKM6Qgk7ZgPdoTMaVJm7PrHh2SuwkDy2nn\n\tP8ta1wVVX21sEcgfgZrV8zYtibgHQ5FAiFH2yDM1dDcQr6HinFEersSa2NM4cQF/YX\n\tvl4LhlJCCMqaFOqvYTNaccKaRLvEZP16D5feb9e0=","Date":"Sat, 29 Jun 2024 02:09:46 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v2 11/25] libtuning: Reactivate macbeth locator","Message-ID":"<20240628230946.GI30900@pendragon.ideasonboard.com>","References":"<20240628104828.2928109-1-stefan.klug@ideasonboard.com>\n\t<20240628104828.2928109-12-stefan.klug@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20240628104828.2928109-12-stefan.klug@ideasonboard.com>","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>"}},{"id":30191,"web_url":"https://patchwork.libcamera.org/comment/30191/","msgid":"<xbjgeh6hokomnqzjbwqevjbkyjpbj3463bfury427fs224hdb6@gk45rg6xuuh3>","date":"2024-07-01T15:48:47","subject":"Re: [PATCH v2 11/25] libtuning: Reactivate macbeth locator","submitter":{"id":184,"url":"https://patchwork.libcamera.org/api/people/184/","name":"Stefan Klug","email":"stefan.klug@ideasonboard.com"},"content":"Hi Laurent,\n\nOn Sat, Jun 29, 2024 at 02:09:46AM +0300, Laurent Pinchart wrote:\n> Hi Stefan,\n> \n> Thank you for the patch.\n> \n> On Fri, Jun 28, 2024 at 12:47:04PM +0200, Stefan Klug wrote:\n> > Add the missing pieces and store the result inside the image object.\n> > \n> > Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> > ---\n> >  utils/tuning/libtuning/image.py   |  1 +\n> >  utils/tuning/libtuning/macbeth.py | 13 ++++++++++---\n> >  utils/tuning/libtuning/utils.py   |  5 +++--\n> >  3 files changed, 14 insertions(+), 5 deletions(-)\n> > \n> > diff --git a/utils/tuning/libtuning/image.py b/utils/tuning/libtuning/image.py\n> > index 2c4d774f11e2..c8911a0ff125 100644\n> > --- a/utils/tuning/libtuning/image.py\n> > +++ b/utils/tuning/libtuning/image.py\n> > @@ -24,6 +24,7 @@ class Image:\n> >          self.lsc_only = False\n> >          self.color = -1\n> >          self.lux = -1\n> > +        self.macbeth = None\n> >  \n> >          try:\n> >              self._load_metadata_exif()\n> > diff --git a/utils/tuning/libtuning/macbeth.py b/utils/tuning/libtuning/macbeth.py\n> > index 28051de8155c..4a2006b013dc 100644\n> > --- a/utils/tuning/libtuning/macbeth.py\n> > +++ b/utils/tuning/libtuning/macbeth.py\n> > @@ -17,12 +17,15 @@ import logging\n> >  from sklearn import cluster as cluster\n> >  \n> >  from .ctt_ransac import get_square_verts, get_square_centres\n> > -\n> > -from libtuning.image import Image\n> > +from .image import Image\n> >  \n> >  logger = logging.getLogger(__name__)\n> >  \n> >  \n> > +class MacbethError(Exception):\n> > +    pass\n> > +\n> > +\n> >  # Reshape image to fixed width without distorting returns image and scale\n> >  # factor\n> >  def reshape(img, width):\n> > @@ -377,7 +380,9 @@ def get_macbeth_chart(img, ref_data):\n> >  \n> >      # Catch macbeth errors and continue with code\n> >      except MacbethError as error:\n> > -        logger.warning(error)\n> > +        # \\todo: This happens so many times in a normal run, that it shadows\n> > +        # all the relevant output\n> > +        # logger.warning(error)\n> >          return (0, None, None, False)\n> >  \n> >  \n> > @@ -527,4 +532,6 @@ def locate_macbeth(image: Image, config: dict):\n> >          logger.warning(f'Macbeth patches have saturated in {image.path.name}')\n> >          return None\n> >  \n> > +    image.macbeth = macbeth\n> > +\n> >      return macbeth\n> > diff --git a/utils/tuning/libtuning/utils.py b/utils/tuning/libtuning/utils.py\n> > index 00cf5a57512f..1e7991e84a70 100644\n> > --- a/utils/tuning/libtuning/utils.py\n> > +++ b/utils/tuning/libtuning/utils.py\n> > @@ -17,7 +17,7 @@ import logging\n> >  \n> >  import libtuning as lt\n> >  from libtuning.image import Image\n> > -from libtuning.macbeth import locate_macbeth\n> > +from .macbeth import locate_macbeth\n> >  \n> >  logger = logging.getLogger(__name__)\n> >  \n> > @@ -92,6 +92,7 @@ def load_images(input_dir: str, config: dict, load_nonlsc: bool, load_lsc: bool)\n> >      images = []\n> >      for f in files:\n> >          color, lux, lsc_only = _parse_image_filename(f)\n> > +        logger.info(f'Process image {f.name} (color={color}, lux={lux}, lsc_only={lsc_only})')\n> \n> Should this go after the color check ?\n\nNo, I also wanted to have an output on the alsc images.\n\n> \n> >          if color is None:\n> \n> And should an error be reported here ?\n\nAh interesting. I added a warning there.\n\n> \n> This hunk seems to be a candidate for a separate patch.\n\nYes, you are right. It has nothing to do with the enabling mac beth. I\nsplit it out.\n\nRegards,\nStefan\n\n> \n> >              continue\n> >  \n> > @@ -127,7 +128,7 @@ def load_images(input_dir: str, config: dict, load_nonlsc: bool, load_lsc: bool)\n> >              continue\n> >  \n> >          # Handle macbeth\n> > -        macbeth = locate_macbeth(config)\n> > +        macbeth = locate_macbeth(image, config)\n> >          if macbeth is None:\n> >              continue\n> >  \n> \n> -- \n> Regards,\n> \n> Laurent Pinchart","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 989E2BD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  1 Jul 2024 15:48:53 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8A7EB62E01;\n\tMon,  1 Jul 2024 17:48:52 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 18D0C604C1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  1 Jul 2024 17:48:51 +0200 (CEST)","from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:89b2:f6c7:b29b:4e5c])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 01F8163D;\n\tMon,  1 Jul 2024 17:48:23 +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=\"Qhn85zs8\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1719848904;\n\tbh=WQIKb5hH8cqQKXCqWXXttBqVZ7l7iEgEBdhQlaNSyoM=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Qhn85zs8Z7mMGMuzSPUr3/y4ULiUxLLc6RUyKNlX08EWi8VO/gIF9PQzVyicuQbdy\n\tem2ZI4SnPwTxl9xuBBtoWNMo1A1mYEA/DDY2I21vegON0Y5wT/4QoKNi7/xIG3kGnF\n\tlRScUgmw7DPWcnxfSpRpNypCp3xmz1uJSTMjNwC8=","Date":"Mon, 1 Jul 2024 17:48:47 +0200","From":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v2 11/25] libtuning: Reactivate macbeth locator","Message-ID":"<xbjgeh6hokomnqzjbwqevjbkyjpbj3463bfury427fs224hdb6@gk45rg6xuuh3>","References":"<20240628104828.2928109-1-stefan.klug@ideasonboard.com>\n\t<20240628104828.2928109-12-stefan.klug@ideasonboard.com>\n\t<20240628230946.GI30900@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20240628230946.GI30900@pendragon.ideasonboard.com>","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>"}}]