Skip to content

Commit

Permalink
Improvements to Point{2,3}D
Browse files Browse the repository at this point in the history
  • Loading branch information
sarlinpe committed Jan 10, 2024
1 parent b900b29 commit 53cbbf6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
5 changes: 3 additions & 2 deletions pycolmap/scene/point2D.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ void BindPoint2D(py::module& m) {
return repr;
});

py::class_<Point2D, std::shared_ptr<Point2D>>(m, "Point2D")
.def(py::init<>())
py::class_<Point2D, std::shared_ptr<Point2D>> PyPoint2D(m, "Point2D");
PyPoint2D.def(py::init<>())
.def(py::init<const Eigen::Vector2d&, size_t>(),
"xy"_a,
"point3D_id"_a = kInvalidPoint3DId)
Expand All @@ -57,4 +57,5 @@ void BindPoint2D(py::module& m) {
.def("__deepcopy__",
[](const Point2D& self, py::dict) { return Point2D(self); })
.def("__repr__", &PrintPoint2D);
MakeDataclass(PyPoint2D);
}
26 changes: 16 additions & 10 deletions pycolmap/scene/point3D.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,21 @@ void BindPoint3D(py::module& m) {
std::to_string(self.size()) + ")";
});

auto PyPoint3D =
py::class_<Point3D, std::shared_ptr<Point3D>>(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_<Point3D, std::shared_ptr<Point3D>> 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);
}

0 comments on commit 53cbbf6

Please sign in to comment.