[libcamera-devel] [PATCH] py: Improve print methods for Transform and ColorSpace objects
David Plowman
david.plowman at raspberrypi.com
Wed May 18 13:26:06 CEST 2022
Hi Laurent
Thanks for the comments.
On Wed, 18 May 2022 at 11:02, Laurent Pinchart
<laurent.pinchart at ideasonboard.com> wrote:
>
> Hi David,
>
> Thank you for the patch.
>
> On Wed, May 18, 2022 at 10:08:01AM +0100, David Plowman via libcamera-devel wrote:
> > They should now print out their meaningful string representations
> > instead of "object at <address>".
> >
> > Signed-off-by: David Plowman <david.plowman at raspberrypi.com>
> > ---
> > src/py/libcamera/pymain.cpp | 6 ++++++
> > 1 file changed, 6 insertions(+)
> >
> > diff --git a/src/py/libcamera/pymain.cpp b/src/py/libcamera/pymain.cpp
> > index fb89975c..2ba5fcbb 100644
> > --- a/src/py/libcamera/pymain.cpp
> > +++ b/src/py/libcamera/pymain.cpp
> > @@ -567,6 +567,9 @@ PYBIND11_MODULE(_libcamera, m)
> > .def("__str__", [](Transform &self) {
> > return "<libcamera.Transform '" + std::string(transformToString(self)) + "'>";
> > })
> > + .def("__repr__", [](Transform &self) {
> > + return "<libcamera.Transform '" + std::string(transformToString(self)) + "'>";
> > + })
>
> Can we do the same as "[PATCH v2 12/13] py: add geometry classes" and
> return a string that would construct an identical Transform object when
> run as Python code ? Same below.
Just to be clear then, you'd prefer a string like (for example)
libcamera.Transform(hflip=False, vflip=False, transpose=False)
?
>
> > .def_property("hflip",
> > [](Transform &self) {
> > return !!(self & Transform::HFlip);
> > @@ -617,6 +620,9 @@ PYBIND11_MODULE(_libcamera, m)
> > .def("__str__", [](ColorSpace &self) {
> > return "<libcamera.ColorSpace '" + self.toString() + "'>";
> > })
> > + .def("__repr__", [](ColorSpace &self) {
> > + return "<libcamera.ColorSpace '" + self.toString() + "'>";
> > + })
> > .def_readwrite("primaries", &ColorSpace::primaries)
> > .def_readwrite("transferFunction", &ColorSpace::transferFunction)
> > .def_readwrite("ycbcrEncoding", &ColorSpace::ycbcrEncoding)
And in this case I'd output (for example)
libcamera.ColorSpace(libcamera.ColorSpace.Primaries.Rec709,
libcamera.ColorSpace.TransferFunction.Srgb,
libcamera.ColorSpace.YcbcrEncoding.Rec601,
libcamera.ColorSpace.Range.Full)
?
In this case I could perhaps "optimise" it to
libcamera.ColorSpace.Jpeg()
so I'd check for "short versions" first?
Thanks
David
>
> --
> Regards,
>
> Laurent Pinchart
More information about the libcamera-devel
mailing list