forked from colmap/pycolmap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cc
108 lines (87 loc) · 3.29 KB
/
main.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <pybind11/eigen.h>
namespace py = pybind11;
#include <colmap/base/pose.h>
#include "estimators/absolute_pose.cc"
#include "estimators/generalized_absolute_pose.cc"
#include "estimators/essential_matrix.cc"
#include "estimators/fundamental_matrix.cc"
#include "estimators/two_view_geometry.cc"
#include "estimators/homography.cc"
#include "homography_decomposition.cc"
#include "transformations.cc"
#include "sift.cc"
#include "helpers.h"
#include "utils.h"
#include "pipeline/sfm.cc"
#include "pipeline/mvs.cc"
#include "pipeline/meshing.cc"
#include "reconstruction/reconstruction.cc"
#include "reconstruction/correspondence_graph.cc"
#include "reconstruction/incremental_triangulator.cc"
void init_reconstruction(py::module &);
void init_transforms(py::module &);
PYBIND11_MODULE(pycolmap, m) {
m.doc() = "COLMAP plugin";
#ifdef VERSION_INFO
m.attr("__version__") = py::str(VERSION_INFO);
#else
m.attr("__version__") = py::str("dev");
#endif
auto PyDevice = py::enum_<Device>(m, "Device")
.value("auto", Device::AUTO)
.value("cpu", Device::CPU)
.value("cuda", Device::CUDA);
AddStringToEnumConstructor(PyDevice);
m.attr("has_cuda") = IsGPU(Device::AUTO);
// Estimators
auto PyRANSACOptions = py::class_<RANSACOptions>(m, "RANSACOptions")
.def(py::init<>([]() {
RANSACOptions options;
options.max_error = 4.0;
options.min_inlier_ratio = 0.01;
options.confidence = 0.9999;
options.min_num_trials = 1000;
options.max_num_trials = 100000;
return options;
}))
.def_readwrite("max_error", &RANSACOptions::max_error)
.def_readwrite("min_inlier_ratio", &RANSACOptions::min_inlier_ratio)
.def_readwrite("confidence", &RANSACOptions::confidence)
.def_readwrite("dyn_num_trials_multiplier", &RANSACOptions::dyn_num_trials_multiplier)
.def_readwrite("min_num_trials", &RANSACOptions::min_num_trials)
.def_readwrite("max_num_trials", &RANSACOptions::max_num_trials);
make_dataclass(PyRANSACOptions);
bind_absolute_pose_estimation(m, PyRANSACOptions);
bind_essential_matrix_estimation(m);
bind_fundamental_matrix_estimation(m);
bind_generalized_absolute_pose_estimation(m);
bind_homography_estimation(m);
bind_two_view_geometry_estimation(m, PyRANSACOptions);
// Homography Decomposition.
m.def("homography_decomposition", &homography_decomposition_estimation,
py::arg("H"),
py::arg("K1"),
py::arg("K2"),
py::arg("points1"),
py::arg("points2"),
"Analytical Homography Decomposition.");
// Reconstruction bindings
init_reconstruction(m);
// Correspondence graph bindings
init_correspondence_graph(m);
// Incremental triangulator bindings
init_incremental_triangulator(m);
// Automatic conversion from python dicts to colmap cameras for backwards compatibility
py::implicitly_convertible<py::dict, colmap::Camera>();
// Transformation Bindings
init_transforms(m);
// Main reconstruction steps
init_sfm(m);
init_mvs(m);
init_meshing(m);
// SIFT feature detector and descriptor
init_sift(m);
py::add_ostream_redirect(m, "ostream");
}