| 1 |
#include "colmap/mvs/model.h" |
| 2 |
|
| 3 |
#include "pycolmap/helpers.h" |
| 4 |
#include "pycolmap/pybind11_extension.h" |
| 5 |
|
| 6 |
#include <filesystem> |
| 7 |
|
| 8 |
#include <pybind11/functional.h> |
| 9 |
#include <pybind11/pybind11.h> |
| 10 |
#include <pybind11/stl.h> |
| 11 |
#include <pybind11/stl_bind.h> |
| 12 |
|
| 13 |
using namespace colmap; |
| 14 |
using namespace pybind11::literals; |
| 15 |
namespace py = pybind11; |
| 16 |
|
| 17 |
void BindMVSModel(py::module& m) { |
| 18 |
py::classh<mvs::Model> PyMVSModel(m, "MVSModel"); |
| 19 |
PyMVSModel.def(py::init<>()) |
| 20 |
.def("read", |
| 21 |
&mvs::Model::Read, |
| 22 |
"path"_a, |
| 23 |
"format"_a, |
| 24 |
"Read the model from the given path in the specified format.") |
| 25 |
.def("read_from_colmap", |
| 26 |
&mvs::Model::ReadFromCOLMAP, |
| 27 |
"path"_a, |
| 28 |
"sparse_path"_a = std::filesystem::path("sparse"), |
| 29 |
"images_path"_a = std::filesystem::path("images"), |
| 30 |
"Read the model from a COLMAP reconstruction.") |
| 31 |
.def("read_from_pmvs", |
| 32 |
&mvs::Model::ReadFromPMVS, |
| 33 |
"path"_a, |
| 34 |
"Read the model from PMVS output.") |
| 35 |
.def("get_image_idx", |
| 36 |
&mvs::Model::GetImageIdx, |
| 37 |
"name"_a, |
| 38 |
"Get the image index for the given image name.") |
| 39 |
.def("get_image_name", |
| 40 |
&mvs::Model::GetImageName, |
| 41 |
"image_idx"_a, |
| 42 |
"Get the image name for the given image index.") |
| 43 |
.def("get_max_overlapping_images", |
| 44 |
&mvs::Model::GetMaxOverlappingImages, |
| 45 |
"num_images"_a, |
| 46 |
"min_triangulation_angle"_a, |
| 47 |
"Determine maximally overlapping images for each image, " |
| 48 |
"sorted by number of shared points subject to a minimum " |
| 49 |
"triangulation angle.") |
| 50 |
.def("get_max_overlapping_images_from_pmvs", |
| 51 |
&mvs::Model::GetMaxOverlappingImagesFromPMVS, |
| 52 |
py::return_value_policy::reference_internal, |
| 53 |
"Get overlapping images defined in the PMVS vis.dat file.") |
| 54 |
.def("compute_depth_ranges", |
| 55 |
&mvs::Model::ComputeDepthRanges, |
| 56 |
"Compute robust minimum and maximum depths from the sparse point " |
| 57 |
"cloud.") |
| 58 |
.def( |
| 59 |
"compute_shared_points", |
| 60 |
&mvs::Model::ComputeSharedPoints, |
| 61 |
"Compute the number of shared points between all overlapping images.") |
| 62 |
.def("compute_triangulation_angles", |
| 63 |
&mvs::Model::ComputeTriangulationAngles, |
| 64 |
"percentile"_a = 50.0f, |
| 65 |
"Compute the median triangulation angles between all overlapping " |
| 66 |
"images.") |
| 67 |
.def("__repr__", [](const mvs::Model& self) { |
| 68 |
std::ostringstream ss; |
| 69 |
ss << "MVSModel(num_images=" << self.images.size() |
| 70 |
<< ", num_points=" << self.points.size() << ")"; |
| 71 |
return ss.str(); |
| 72 |
}); |
| 73 |
} |