diff --git a/src/pycolmap/helpers.h b/src/pycolmap/helpers.h index e9edb4dd7..5f58153d1 100644 --- a/src/pycolmap/helpers.h +++ b/src/pycolmap/helpers.h @@ -44,7 +44,8 @@ void AddStringToEnumConstructor(py::enum_& enm) { enm.def(py::init([enm](const std::string& value) { return PyStringToEnum(enm, py::str(value)); // str constructor }), - "value"_a); + "name"_a); + enm.attr("__repr__") = enm.attr("__str__"); py::implicitly_convertible(); } diff --git a/src/pycolmap/scene/two_view_geometry.cc b/src/pycolmap/scene/two_view_geometry.cc index 9a5a241ac..7b58a7f8b 100644 --- a/src/pycolmap/scene/two_view_geometry.cc +++ b/src/pycolmap/scene/two_view_geometry.cc @@ -16,9 +16,9 @@ using namespace pybind11::literals; namespace py = pybind11; void BindTwoViewGeometryScene(py::module& m) { - py::enum_(m, - "TwoViewGeometryConfiguration") - .value("UNDEFINED", TwoViewGeometry::UNDEFINED) + py::enum_ PyTwoViewGeometryConfiguration( + m, "TwoViewGeometryConfiguration"); + PyTwoViewGeometryConfiguration.value("UNDEFINED", TwoViewGeometry::UNDEFINED) .value("DEGENERATE", TwoViewGeometry::DEGENERATE) .value("CALIBRATED", TwoViewGeometry::CALIBRATED) .value("UNCALIBRATED", TwoViewGeometry::UNCALIBRATED) @@ -27,6 +27,7 @@ void BindTwoViewGeometryScene(py::module& m) { .value("PLANAR_OR_PANORAMIC", TwoViewGeometry::PLANAR_OR_PANORAMIC) .value("WATERMARK", TwoViewGeometry::WATERMARK) .value("MULTIPLE", TwoViewGeometry::MULTIPLE); + AddStringToEnumConstructor(PyTwoViewGeometryConfiguration); py::class_ PyTwoViewGeometry(m, "TwoViewGeometry"); PyTwoViewGeometry.def(py::init<>())