diff --git a/pycolmap/scene/point2D.h b/pycolmap/scene/point2D.h index 185b729..c7d63cb 100644 --- a/pycolmap/scene/point2D.h +++ b/pycolmap/scene/point2D.h @@ -45,8 +45,8 @@ void BindPoint2D(py::module& m) { return repr; }); - py::class_>(m, "Point2D") - .def(py::init<>()) + py::class_> PyPoint2D(m, "Point2D"); + PyPoint2D.def(py::init<>()) .def(py::init(), "xy"_a, "point3D_id"_a = kInvalidPoint3DId) @@ -57,4 +57,5 @@ void BindPoint2D(py::module& m) { .def("__deepcopy__", [](const Point2D& self, py::dict) { return Point2D(self); }) .def("__repr__", &PrintPoint2D); + MakeDataclass(PyPoint2D); } diff --git a/pycolmap/scene/point3D.h b/pycolmap/scene/point3D.h index 7781704..2c36786 100644 --- a/pycolmap/scene/point3D.h +++ b/pycolmap/scene/point3D.h @@ -24,15 +24,21 @@ void BindPoint3D(py::module& m) { std::to_string(self.size()) + ")"; }); - auto PyPoint3D = - py::class_>(m, "Point3D") - .def(py::init<>()) - .def_readwrite("xyz", &Point3D::xyz) - .def_readwrite("color", &Point3D::color) - .def_readwrite("error", &Point3D::error) - .def_readwrite("track", &Point3D::track) - .def("__copy__", [](const Point3D& self) { return Point3D(self); }) - .def("__deepcopy__", - [](const Point3D& self, py::dict) { return Point3D(self); }); + py::class_> PyPoint3D(m, "Point3D"); + PyPoint3D.def(py::init<>()) + .def_readwrite("xyz", &Point3D::xyz) + .def_readwrite("color", &Point3D::color) + .def_readwrite("error", &Point3D::error) + .def_readwrite("track", &Point3D::track) + .def("__copy__", [](const Point3D& self) { return Point3D(self); }) + .def("__deepcopy__", + [](const Point3D& self, py::dict) { return Point3D(self); }) + .def("__repr__", [](const Point3D& self) { + std::stringstream ss; + ss << "Point3D(xyz=[" << self.xyz.format(vec_fmt) << "], color=[" + << self.color.format(vec_fmt) << "], error=" << self.error + << ", track=Track(length=" << self.track.Length() << "))"; + return ss.str(); + }); MakeDataclass(PyPoint3D); }