Skip to content

Commit

Permalink
Add copy constructor support for solver-related ceres bindings (colma…
Browse files Browse the repository at this point in the history
…p#3059)

For similar purpose as cvg/pyceres#62, just in
the other direction.
  • Loading branch information
B1ueber2y authored and liuzhen19 committed Dec 30, 2024
1 parent 7f79164 commit 123bda2
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/pycolmap/estimators/ceres_bindings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,10 @@ void BindCeresTypes(py::module& m) {

void BindCeresSolver(py::module& m) {
using Options = ceres::Solver::Options;
py::class_<Options> PyOptions(m, "SolverOptions", py::module_local());
py::class_<Options, std::shared_ptr<Options>> PyOptions(
m, "SolverOptions", py::module_local());
PyOptions.def(py::init<>())
.def(py::init<const Options&>())
.def("IsValid", &Options::IsValid)
.def_readwrite("minimizer_type", &Options::minimizer_type)
.def_readwrite("line_search_direction_type",
Expand Down Expand Up @@ -262,8 +264,10 @@ void BindCeresSolver(py::module& m) {
MakeDataclass(PyOptions);

using Summary = ceres::Solver::Summary;
py::class_<Summary> PySummary(m, "SolverSummary", py::module_local());
py::class_<Summary, std::shared_ptr<Summary>> PySummary(
m, "SolverSummary", py::module_local());
PySummary.def(py::init<>())
.def(py::init<const Summary&>())
.def("BriefReport", &Summary::BriefReport)
.def("FullReport", &Summary::FullReport)
.def("IsSolutionUsable", &Summary::IsSolutionUsable)
Expand Down Expand Up @@ -362,9 +366,10 @@ void BindCeresSolver(py::module& m) {
MakeDataclass(PySummary);

using IterSummary = ceres::IterationSummary;
py::class_<IterSummary> PyIterSummary(
py::class_<IterSummary, std::shared_ptr<IterSummary>> PyIterSummary(
m, "IterationSummary", py::module_local());
PyIterSummary.def(py::init<>())
.def(py::init<const IterSummary&>())
.def_readonly("iteration", &IterSummary::iteration)
.def_readonly("step_is_valid", &IterSummary::step_is_valid)
.def_readonly("step_is_nonmonotonic", &IterSummary::step_is_nonmonotonic)
Expand Down

0 comments on commit 123bda2

Please sign in to comment.