[{"id":23039,"web_url":"https://patchwork.libcamera.org/comment/23039/","msgid":"<YoTEHksggiCcdDzo@pendragon.ideasonboard.com>","date":"2022-05-18T10:02:06","subject":"Re: [libcamera-devel] [PATCH] py: Improve print methods for\n\tTransform and ColorSpace objects","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi David,\n\nThank you for the patch.\n\nOn Wed, May 18, 2022 at 10:08:01AM +0100, David Plowman via libcamera-devel wrote:\n> They should now print out their meaningful string representations\n> instead of \"object at <address>\".\n> \n> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> ---\n>  src/py/libcamera/pymain.cpp | 6 ++++++\n>  1 file changed, 6 insertions(+)\n> \n> diff --git a/src/py/libcamera/pymain.cpp b/src/py/libcamera/pymain.cpp\n> index fb89975c..2ba5fcbb 100644\n> --- a/src/py/libcamera/pymain.cpp\n> +++ b/src/py/libcamera/pymain.cpp\n> @@ -567,6 +567,9 @@ PYBIND11_MODULE(_libcamera, m)\n>  \t\t.def(\"__str__\", [](Transform &self) {\n>  \t\t\treturn \"<libcamera.Transform '\" + std::string(transformToString(self)) + \"'>\";\n>  \t\t})\n> +\t\t.def(\"__repr__\", [](Transform &self) {\n> +\t\t\treturn \"<libcamera.Transform '\" + std::string(transformToString(self)) + \"'>\";\n> +\t\t})\n\nCan we do the same as \"[PATCH v2 12/13] py: add geometry classes\" and\nreturn a string that would construct an identical Transform object when\nrun as Python code ? Same below.\n\n>  \t\t.def_property(\"hflip\",\n>  \t\t\t      [](Transform &self) {\n>  \t\t\t\t      return !!(self & Transform::HFlip);\n> @@ -617,6 +620,9 @@ PYBIND11_MODULE(_libcamera, m)\n>  \t\t.def(\"__str__\", [](ColorSpace &self) {\n>  \t\t\treturn \"<libcamera.ColorSpace '\" + self.toString() + \"'>\";\n>  \t\t})\n> +\t\t.def(\"__repr__\", [](ColorSpace &self) {\n> +\t\t\treturn \"<libcamera.ColorSpace '\" + self.toString() + \"'>\";\n> +\t\t})\n>  \t\t.def_readwrite(\"primaries\", &ColorSpace::primaries)\n>  \t\t.def_readwrite(\"transferFunction\", &ColorSpace::transferFunction)\n>  \t\t.def_readwrite(\"ycbcrEncoding\", &ColorSpace::ycbcrEncoding)","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 CF2BBC3256\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 18 May 2022 10:02:15 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1DC6A65659;\n\tWed, 18 May 2022 12:02:15 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9EF7565656\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 18 May 2022 12:02:13 +0200 (CEST)","from pendragon.ideasonboard.com (unknown [45.131.31.124])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0F145475;\n\tWed, 18 May 2022 12:02:12 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1652868135;\n\tbh=uSgkEnsizPaFuozq6cu0y6Lqr4mwG7Nqmsavpq1MMrQ=;\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=mPTjbNOMvUijOcXWZUevChuPGAdmursSjTXIvdh2U/QDYbLgPgWSCzP6XN835Ynu/\n\t1TQ7bWRtLPhIBs3Uo+QSrb/H6qGh2hkuhoPgqzr5fOJ8hlK/b4F5PZDn883SQoKJSs\n\tfgrjLc0wzC/Z7nDrcIierVTogAATph0gjv2miSpZsOaKuxmj3Kx9U1JmE9NM2FDdSv\n\tNQE0/DSWDN4dstJMsFqYmTwxXg+ByzvAnxVijMazo0/WIMSbNbJNV95ADE0zwpQvfm\n\t5e8f7cP0mN3dI4s2/QtJZ8IHEE/JarNBmZyew9ybWAml6ic248uOXQ447NhKvD9v6+\n\tfLpmZKj0DypKw==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1652868133;\n\tbh=uSgkEnsizPaFuozq6cu0y6Lqr4mwG7Nqmsavpq1MMrQ=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=jhmAEhCSaIQyUfghi6TaJb6qw8HSSCMYxDGvvxW4DfYhVLMeY4ttHCs2gKYYeMCI6\n\tolMfOYGHOt4QaVOM4OSiqXGvYm0/N6m1himsBsHWEquuIUgHwhaSilIfW4Paqzfgbp\n\tI9Xfr2PQDCkUzbuIICN+j52PMvL2br4kvOxl3qG4="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"jhmAEhCS\"; dkim-atps=neutral","Date":"Wed, 18 May 2022 13:02:06 +0300","To":"David Plowman <david.plowman@raspberrypi.com>","Message-ID":"<YoTEHksggiCcdDzo@pendragon.ideasonboard.com>","References":"<20220518090801.7229-1-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220518090801.7229-1-david.plowman@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH] py: Improve print methods for\n\tTransform and ColorSpace objects","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":23048,"web_url":"https://patchwork.libcamera.org/comment/23048/","msgid":"<CAHW6GY++=nZ7bJhtWS2W1if5v_yJ9wEeNXqfd=Hc+M62kXp17g@mail.gmail.com>","date":"2022-05-18T11:26:06","subject":"Re: [libcamera-devel] [PATCH] py: Improve print methods for\n\tTransform and ColorSpace objects","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"content":"Hi Laurent\n\nThanks for the comments.\n\nOn Wed, 18 May 2022 at 11:02, Laurent Pinchart\n<laurent.pinchart@ideasonboard.com> wrote:\n>\n> Hi David,\n>\n> Thank you for the patch.\n>\n> On Wed, May 18, 2022 at 10:08:01AM +0100, David Plowman via libcamera-devel wrote:\n> > They should now print out their meaningful string representations\n> > instead of \"object at <address>\".\n> >\n> > Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> > ---\n> >  src/py/libcamera/pymain.cpp | 6 ++++++\n> >  1 file changed, 6 insertions(+)\n> >\n> > diff --git a/src/py/libcamera/pymain.cpp b/src/py/libcamera/pymain.cpp\n> > index fb89975c..2ba5fcbb 100644\n> > --- a/src/py/libcamera/pymain.cpp\n> > +++ b/src/py/libcamera/pymain.cpp\n> > @@ -567,6 +567,9 @@ PYBIND11_MODULE(_libcamera, m)\n> >               .def(\"__str__\", [](Transform &self) {\n> >                       return \"<libcamera.Transform '\" + std::string(transformToString(self)) + \"'>\";\n> >               })\n> > +             .def(\"__repr__\", [](Transform &self) {\n> > +                     return \"<libcamera.Transform '\" + std::string(transformToString(self)) + \"'>\";\n> > +             })\n>\n> Can we do the same as \"[PATCH v2 12/13] py: add geometry classes\" and\n> return a string that would construct an identical Transform object when\n> run as Python code ? Same below.\n\nJust to be clear then, you'd prefer a string like (for example)\n\nlibcamera.Transform(hflip=False, vflip=False, transpose=False)\n\n?\n\n>\n> >               .def_property(\"hflip\",\n> >                             [](Transform &self) {\n> >                                     return !!(self & Transform::HFlip);\n> > @@ -617,6 +620,9 @@ PYBIND11_MODULE(_libcamera, m)\n> >               .def(\"__str__\", [](ColorSpace &self) {\n> >                       return \"<libcamera.ColorSpace '\" + self.toString() + \"'>\";\n> >               })\n> > +             .def(\"__repr__\", [](ColorSpace &self) {\n> > +                     return \"<libcamera.ColorSpace '\" + self.toString() + \"'>\";\n> > +             })\n> >               .def_readwrite(\"primaries\", &ColorSpace::primaries)\n> >               .def_readwrite(\"transferFunction\", &ColorSpace::transferFunction)\n> >               .def_readwrite(\"ycbcrEncoding\", &ColorSpace::ycbcrEncoding)\n\nAnd in this case I'd output (for example)\n\nlibcamera.ColorSpace(libcamera.ColorSpace.Primaries.Rec709,\nlibcamera.ColorSpace.TransferFunction.Srgb,\nlibcamera.ColorSpace.YcbcrEncoding.Rec601,\nlibcamera.ColorSpace.Range.Full)\n\n?\n\nIn this case I could perhaps \"optimise\" it to\n\nlibcamera.ColorSpace.Jpeg()\n\nso I'd check for \"short versions\" first?\n\nThanks\nDavid\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 5F648C3256\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 18 May 2022 11:26:20 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 653FF65659;\n\tWed, 18 May 2022 13:26:19 +0200 (CEST)","from mail-wr1-x435.google.com (mail-wr1-x435.google.com\n\t[IPv6:2a00:1450:4864:20::435])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B56CA65656\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 18 May 2022 13:26:17 +0200 (CEST)","by mail-wr1-x435.google.com with SMTP id h5so1122360wrb.11\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 18 May 2022 04:26:17 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1652873179;\n\tbh=cqPwqoQ6pLcACUU7ZHdJ7PV3g5SRjfzvjEVQMow60kM=;\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=zduNQYYFB1dqhM1co79YzWEeaBXLt6SeUYJECPPM/gg8iBu3sUU55ttbkyv8o+Wkb\n\tMEEXGTiq+P2QoXE6VSuHjISAYoL9O3BhZPXz91ltcyEnSG0ZvMwGuaMnIpkYRVugiS\n\tklg9vZEhTutObp+pRQ6e7GvqFTZS8nfolMp7ARMHfX1RxB06K/ptfMvbCMhiJJ6Eqb\n\tI2Vm8rLH9eERUahdE0imOzQo4OjjonsrXBBDX9YmV26gMrplKGHXwjQ7yBcRIbR4Wr\n\tBZ6kX1THKONpLOfEkOldX9Mie7qMIhCFTy0alC7whghA5iIDC+aSWHF21dBUzXnaL6\n\tybEQ1mVE9Jcrg==","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=SnYO7QiVn+80PyMyxFIXYUjD5Jz9DsTs8Ow/p+jnKIo=;\n\tb=rh3nEn6H/LI1+46PCeiox7sr0Vh/nwV4/wIT2/s6xWym004tWVSDV5jn7N/wLDsx5J\n\tid/m6PE0C0GUyFX9qFWUz2g/32J/Y2l1ZJdWg+8HZvUVD03NvyfE6XcAyv/8fvQO/vvg\n\tUWQvsdokYifid9RrJbA+bkcwT7o970v+XhigmHmxyy82h4NelfKfzRteIisqc/QqTxc9\n\twLQ7wck7WCyP+DY2pOCjJ+b8wnlmDq6gSeWrKYwKHJUL6FC2rCgpRckVJBHPTRHTwsuS\n\tYwFRY/G9e2wT6nW/BembYd9l3s0nTf5tmdyrNIoUizdKL1nT1wN4YBLciKqAjSSbSQFK\n\tCZqg=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"rh3nEn6H\"; 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=SnYO7QiVn+80PyMyxFIXYUjD5Jz9DsTs8Ow/p+jnKIo=;\n\tb=6DvxmzpInR4CAuIzCyaUmfrAHPVN28b4sSb1hl/5nbeeW9VrOGMIXXwXWkFL2wxlSj\n\tcqs7mVowWOAeF7Z4Jj1/ayJ6j1rlmR4sqSMn/jUbLdbNX+39YOOixsgzMVf/WVmbcmkB\n\trP3TIbj2UpP0Kwp1w5jvK6SYZ2KooF8UQ07CUOv5TtdQOB9q5xoUw1RiGrSZZpVVxchm\n\t86hxaOAIgeCimTJfZmo72wwBjElmmTXOqj4P8XOnQg4xBebxQCiL2cnIMqPUlLrtvAK3\n\tu69W3q/tP/rgV4mN/vH4kx/GP6CSpuaHZRR0R0aI0bdv1e/+LeUneTeTEhYfPahwQXjM\n\t5OZg==","X-Gm-Message-State":"AOAM5327q7BOMbLcneiOPMnLLwtk+1sAIj6SG5coZk+r6ehuu+pNGmqA\n\tJXY6P1vkpRMN5M0WXrsHA8e2lmp5SMqXPngav/NkXoDzlhb51A==","X-Google-Smtp-Source":"ABdhPJy8Wy8zHsAE9FWkIqP5Lv2i1UiZ4/xgpQjb7+nM4nwyTVEopl1W/LdrDPssMQ9Jfa+q1iYUUPcofNe5vyhTV68=","X-Received":"by 2002:a05:6000:1681:b0:20d:1348:631 with SMTP id\n\ty1-20020a056000168100b0020d13480631mr8049050wrd.67.1652873177383;\n\tWed, 18 May 2022 04:26:17 -0700 (PDT)","MIME-Version":"1.0","References":"<20220518090801.7229-1-david.plowman@raspberrypi.com>\n\t<YoTEHksggiCcdDzo@pendragon.ideasonboard.com>","In-Reply-To":"<YoTEHksggiCcdDzo@pendragon.ideasonboard.com>","Date":"Wed, 18 May 2022 12:26:06 +0100","Message-ID":"<CAHW6GY++=nZ7bJhtWS2W1if5v_yJ9wEeNXqfd=Hc+M62kXp17g@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH] py: Improve print methods for\n\tTransform and ColorSpace objects","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":"David Plowman via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"David Plowman <david.plowman@raspberrypi.com>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":23050,"web_url":"https://patchwork.libcamera.org/comment/23050/","msgid":"<YoTaLuB4vp8AHrdR@pendragon.ideasonboard.com>","date":"2022-05-18T11:36:14","subject":"Re: [libcamera-devel] [PATCH] py: Improve print methods for\n\tTransform and ColorSpace objects","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi David,\n\nOn Wed, May 18, 2022 at 12:26:06PM +0100, David Plowman wrote:\n> On Wed, 18 May 2022 at 11:02, Laurent Pinchart wrote:\n> > On Wed, May 18, 2022 at 10:08:01AM +0100, David Plowman via libcamera-devel wrote:\n> > > They should now print out their meaningful string representations\n> > > instead of \"object at <address>\".\n> > >\n> > > Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> > > ---\n> > >  src/py/libcamera/pymain.cpp | 6 ++++++\n> > >  1 file changed, 6 insertions(+)\n> > >\n> > > diff --git a/src/py/libcamera/pymain.cpp b/src/py/libcamera/pymain.cpp\n> > > index fb89975c..2ba5fcbb 100644\n> > > --- a/src/py/libcamera/pymain.cpp\n> > > +++ b/src/py/libcamera/pymain.cpp\n> > > @@ -567,6 +567,9 @@ PYBIND11_MODULE(_libcamera, m)\n> > >               .def(\"__str__\", [](Transform &self) {\n> > >                       return \"<libcamera.Transform '\" + std::string(transformToString(self)) + \"'>\";\n> > >               })\n> > > +             .def(\"__repr__\", [](Transform &self) {\n> > > +                     return \"<libcamera.Transform '\" + std::string(transformToString(self)) + \"'>\";\n> > > +             })\n> >\n> > Can we do the same as \"[PATCH v2 12/13] py: add geometry classes\" and\n> > return a string that would construct an identical Transform object when\n> > run as Python code ? Same below.\n> \n> Just to be clear then, you'd prefer a string like (for example)\n> \n> libcamera.Transform(hflip=False, vflip=False, transpose=False)\n> \n> ?\n\nIt's possibly a bit long. I wonder if we should expose the C++ presets.\n\n> > >               .def_property(\"hflip\",\n> > >                             [](Transform &self) {\n> > >                                     return !!(self & Transform::HFlip);\n> > > @@ -617,6 +620,9 @@ PYBIND11_MODULE(_libcamera, m)\n> > >               .def(\"__str__\", [](ColorSpace &self) {\n> > >                       return \"<libcamera.ColorSpace '\" + self.toString() + \"'>\";\n> > >               })\n> > > +             .def(\"__repr__\", [](ColorSpace &self) {\n> > > +                     return \"<libcamera.ColorSpace '\" + self.toString() + \"'>\";\n> > > +             })\n> > >               .def_readwrite(\"primaries\", &ColorSpace::primaries)\n> > >               .def_readwrite(\"transferFunction\", &ColorSpace::transferFunction)\n> > >               .def_readwrite(\"ycbcrEncoding\", &ColorSpace::ycbcrEncoding)\n> \n> And in this case I'd output (for example)\n> \n> libcamera.ColorSpace(libcamera.ColorSpace.Primaries.Rec709,\n> libcamera.ColorSpace.TransferFunction.Srgb,\n> libcamera.ColorSpace.YcbcrEncoding.Rec601,\n> libcamera.ColorSpace.Range.Full)\n> \n> ?\n\nOuch, that hurts.\n\n> In this case I could perhaps \"optimise\" it to\n> \n> libcamera.ColorSpace.Jpeg()\n> \n> so I'd check for \"short versions\" first?\n\nThat would be good yes, but in the non-standard case, I wonder if such a\nlong representation is acceptable. Tomi, any opinion ?","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 4456FC3256\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 18 May 2022 11:36:23 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 80A2065659;\n\tWed, 18 May 2022 13:36:22 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7D8EF65656\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 18 May 2022 13:36:21 +0200 (CEST)","from pendragon.ideasonboard.com (unknown [45.131.31.124])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 020FAE50;\n\tWed, 18 May 2022 13:36:20 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1652873782;\n\tbh=0S0bj735sXOrD2TwJvIkYLePj6ci7mvOWxMOoNPcv00=;\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=sd/AwmP1H2nWqW+IOY+bP+5BZK2GP54S2CmJPTgMoXgfsrZOm46RuCk9rzlm/1ZdB\n\tcnO0YkqWQ09vNr0pZwYtHDOUop5zz5483mWa8mkXwybm9L4jYf02+UE8OzkIJTdJpw\n\t9GOiY6/Ct1q4hzfLsohD8q/yicsUCixhfJTWXwoDZekKwgWVjS/oCA77mIslGo5ufc\n\tY0mB8UnZCKk4phVvzahxRRK+l6Lfv3AnmrV7olqFKE95bPMM527cyaa80ToJ5UueJV\n\twjPBHAvYFGUroq3TFIr3Vw+Eh4m/dBVa7ApvVFdm4BRwQ0Qv1QgClK7tXIpe0pvi0y\n\tiiAcoHRdI3YvQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1652873781;\n\tbh=0S0bj735sXOrD2TwJvIkYLePj6ci7mvOWxMOoNPcv00=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=LMJffap2WELm3KUHV9Z5fXSRMC+O2/8VYSpp1X0TBn7HDLtGnteIRVIgWTsXz4vq1\n\t6FzXctMBOtMFkh729JfYJ8ffVPzIcBvJeyuHTX+8Xlu9hgPrsCi87utyRDfXIWOric\n\tMSJY/aUlwQ+pKY0BdJmVymcl5azblkT3XphThVl8="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"LMJffap2\"; dkim-atps=neutral","Date":"Wed, 18 May 2022 14:36:14 +0300","To":"David Plowman <david.plowman@raspberrypi.com>","Message-ID":"<YoTaLuB4vp8AHrdR@pendragon.ideasonboard.com>","References":"<20220518090801.7229-1-david.plowman@raspberrypi.com>\n\t<YoTEHksggiCcdDzo@pendragon.ideasonboard.com>\n\t<CAHW6GY++=nZ7bJhtWS2W1if5v_yJ9wEeNXqfd=Hc+M62kXp17g@mail.gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<CAHW6GY++=nZ7bJhtWS2W1if5v_yJ9wEeNXqfd=Hc+M62kXp17g@mail.gmail.com>","Subject":"Re: [libcamera-devel] [PATCH] py: Improve print methods for\n\tTransform and ColorSpace objects","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 <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":23346,"web_url":"https://patchwork.libcamera.org/comment/23346/","msgid":"<4f8d81e1-d7aa-eef0-dc8c-e61473259b8f@ideasonboard.com>","date":"2022-06-07T13:29:42","subject":"Re: [libcamera-devel] [PATCH] py: Improve print methods for\n\tTransform and ColorSpace objects","submitter":{"id":109,"url":"https://patchwork.libcamera.org/api/people/109/","name":"Tomi Valkeinen","email":"tomi.valkeinen@ideasonboard.com"},"content":"Hi,\n\nSorry, missed this.\n\nOn 18/05/2022 14:36, Laurent Pinchart via libcamera-devel wrote:\n> Hi David,\n> \n> On Wed, May 18, 2022 at 12:26:06PM +0100, David Plowman wrote:\n>> On Wed, 18 May 2022 at 11:02, Laurent Pinchart wrote:\n>>> On Wed, May 18, 2022 at 10:08:01AM +0100, David Plowman via libcamera-devel wrote:\n>>>> They should now print out their meaningful string representations\n>>>> instead of \"object at <address>\".\n>>>>\n>>>> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n>>>> ---\n>>>>   src/py/libcamera/pymain.cpp | 6 ++++++\n>>>>   1 file changed, 6 insertions(+)\n>>>>\n>>>> diff --git a/src/py/libcamera/pymain.cpp b/src/py/libcamera/pymain.cpp\n>>>> index fb89975c..2ba5fcbb 100644\n>>>> --- a/src/py/libcamera/pymain.cpp\n>>>> +++ b/src/py/libcamera/pymain.cpp\n>>>> @@ -567,6 +567,9 @@ PYBIND11_MODULE(_libcamera, m)\n>>>>                .def(\"__str__\", [](Transform &self) {\n>>>>                        return \"<libcamera.Transform '\" + std::string(transformToString(self)) + \"'>\";\n>>>>                })\n>>>> +             .def(\"__repr__\", [](Transform &self) {\n>>>> +                     return \"<libcamera.Transform '\" + std::string(transformToString(self)) + \"'>\";\n>>>> +             })\n>>>\n>>> Can we do the same as \"[PATCH v2 12/13] py: add geometry classes\" and\n>>> return a string that would construct an identical Transform object when\n>>> run as Python code ? Same below.\n>>\n>> Just to be clear then, you'd prefer a string like (for example)\n>>\n>> libcamera.Transform(hflip=False, vflip=False, transpose=False)\n>>\n>> ?\n> \n> It's possibly a bit long. I wonder if we should expose the C++ presets.\n\nI think this is still okayish.\n\n>>>>                .def_property(\"hflip\",\n>>>>                              [](Transform &self) {\n>>>>                                      return !!(self & Transform::HFlip);\n>>>> @@ -617,6 +620,9 @@ PYBIND11_MODULE(_libcamera, m)\n>>>>                .def(\"__str__\", [](ColorSpace &self) {\n>>>>                        return \"<libcamera.ColorSpace '\" + self.toString() + \"'>\";\n>>>>                })\n>>>> +             .def(\"__repr__\", [](ColorSpace &self) {\n>>>> +                     return \"<libcamera.ColorSpace '\" + self.toString() + \"'>\";\n>>>> +             })\n>>>>                .def_readwrite(\"primaries\", &ColorSpace::primaries)\n>>>>                .def_readwrite(\"transferFunction\", &ColorSpace::transferFunction)\n>>>>                .def_readwrite(\"ycbcrEncoding\", &ColorSpace::ycbcrEncoding)\n>>\n>> And in this case I'd output (for example)\n>>\n>> libcamera.ColorSpace(libcamera.ColorSpace.Primaries.Rec709,\n>> libcamera.ColorSpace.TransferFunction.Srgb,\n>> libcamera.ColorSpace.YcbcrEncoding.Rec601,\n>> libcamera.ColorSpace.Range.Full)\n>>\n>> ?\n> \n> Ouch, that hurts.\n\nYes, that's a bit long...\n\n>> In this case I could perhaps \"optimise\" it to\n>>\n>> libcamera.ColorSpace.Jpeg()\n>>\n>> so I'd check for \"short versions\" first?\n> \n> That would be good yes, but in the non-standard case, I wonder if such a\n> long representation is acceptable. Tomi, any opinion ?\n\nI don't know how useful it is to try to stick to the __repr__ rule of \noutputting a python code string. It's nice for simple classes, but it \ndoesn't work for anything more complex. And I don't know if there's any \npractical use for the feature.\n\nIt also doesn't work if implemented \"naively\", as e.g. I usually \"import \nlibcamera as libcam\", and then \"libcamera.Transform\" doesn't work. I'm \nnot sure how it could be made smarter.\n\nColorSpace and Transform are kind of simple, but sounds like at least \nfor ColorSpace it would require perhaps a lot of work to output \nsomething that's not overly long. And I just don't quite see the big \nbenefit.\n\nHowever, there is a big benefit in outputting _something_ that describes \nthe object, which is what the original patch does.\n\nSo, perhaps for Transform, output \"libcamera.Transform(hflip=False, \nvflip=False, transpose=False)\" which should be trivial to implement, and \nfor ColorSpace just use the C++ toString()?\n\nWe can always improve it later.\n\n  Tomi","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 93A39BD160\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  7 Jun 2022 13:29:49 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6892A65635;\n\tTue,  7 Jun 2022 15:29:46 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7223D633A5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  7 Jun 2022 15:29:45 +0200 (CEST)","from [192.168.1.111] (91-156-85-209.elisa-laajakaista.fi\n\t[91.156.85.209])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id EBBF480A;\n\tTue,  7 Jun 2022 15:29:44 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1654608586;\n\tbh=PQmEFgLbJUxhG6uAq2CRjPkqzlCLz1y2Txh+mdGjAb0=;\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=vbY4wQi57kOXj77dLwweKRBuNv2lgrF/fijFMuFk+hIRzJQarCxm+Iyg35AnINy9j\n\tEP1wbixzBSCgJAitKkIaHteqVnbdMAsgIESbvWmIzAoo2aQE27Ud7MheOs9tFtIc9m\n\tNKhTQi6tGYbGHDOTzoeZFI5gp0k6GKUD/n0UqB6ht17ym/ShPNioBRXq1S1GtShw1F\n\trqGjKho02KrkZaC974ZEggVJSOUQQQdDUOJypVO7jxoY59/kutB6DXPWIk+Y1/71Ch\n\tWwzUrEGpqJqe8VkWfRcCRxpfZu4Ii8k8fSjNvaVXBxiPRIMuSHdtHEU3FRp95hNJUB\n\tm5FMo93OfAAxQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1654608585;\n\tbh=PQmEFgLbJUxhG6uAq2CRjPkqzlCLz1y2Txh+mdGjAb0=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=julqw9roR74mwluDhCwnDPhRMfKBZbqSintt/T53ToEVrftuiEDrHMH+e+e47iSko\n\tQYbCmpp9KNzL6Z7fJ1ggNxEuaARiUN3+bOqwW52koibrBves4GSqTD3TuMwTteIWE4\n\ti4yndtZo90J2IafAAvYRpJR4Fig656pnlt77CRdY="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"julqw9ro\"; dkim-atps=neutral","Message-ID":"<4f8d81e1-d7aa-eef0-dc8c-e61473259b8f@ideasonboard.com>","Date":"Tue, 7 Jun 2022 16:29:42 +0300","MIME-Version":"1.0","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101\n\tThunderbird/91.9.1","Content-Language":"en-US","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tDavid Plowman <david.plowman@raspberrypi.com>","References":"<20220518090801.7229-1-david.plowman@raspberrypi.com>\n\t<YoTEHksggiCcdDzo@pendragon.ideasonboard.com>\n\t<CAHW6GY++=nZ7bJhtWS2W1if5v_yJ9wEeNXqfd=Hc+M62kXp17g@mail.gmail.com>\n\t<YoTaLuB4vp8AHrdR@pendragon.ideasonboard.com>","In-Reply-To":"<YoTaLuB4vp8AHrdR@pendragon.ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH] py: Improve print methods for\n\tTransform and ColorSpace objects","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":"Tomi Valkeinen via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]