Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added input model support in incremental mapping pipeline #84

Merged
merged 3 commits into from
Apr 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions pipeline/sfm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,22 @@ std::map<size_t, Reconstruction> incremental_mapping(
const py::object database_path_,
const py::object image_path_,
const py::object output_path_,
const IncrementalMapperOptions& options) {
const IncrementalMapperOptions& options,
const py::object input_path_) {
std::string database_path = py::str(database_path_).cast<std::string>();
THROW_CHECK_FILE_EXISTS(database_path);
std::string image_path = py::str(image_path_).cast<std::string>();
THROW_CHECK_DIR_EXISTS(image_path);
std::string input_path = py::str(input_path_).cast<std::string>();
std::string output_path = py::str(output_path_).cast<std::string>();
CreateDirIfNotExists(output_path);

py::gil_scoped_release release;
ReconstructionManager reconstruction_manager;
if (input_path != "") {
THROW_CHECK_DIR_EXISTS(input_path);
reconstruction_manager.Read(input_path);
}
IncrementalMapperController mapper(
&options, image_path, database_path, &reconstruction_manager);

Expand Down Expand Up @@ -103,12 +109,13 @@ std::map<size_t, Reconstruction> incremental_mapping(
const py::object image_path_,
const py::object output_path_,
const int num_threads,
const int min_num_matches) {
const int min_num_matches,
const py::object input_path_) {
IncrementalMapperOptions options;
options.num_threads = num_threads;
options.min_num_matches = min_num_matches;
return incremental_mapping(
database_path_, image_path_, output_path_, options);
database_path_, image_path_, output_path_, options, input_path_);
}

void init_sfm(py::module& m) {
Expand Down Expand Up @@ -194,24 +201,28 @@ void init_sfm(py::module& m) {
const py::object,
const py::object,
const py::object,
const IncrementalMapperOptions&)>(&incremental_mapping),
const IncrementalMapperOptions&,
const py::object)>(&incremental_mapping),
py::arg("database_path"),
py::arg("image_path"),
py::arg("output_path"),
py::arg("options") = mapper_options,
py::arg("input_path") = py::str(""),
"Triangulate 3D points from known poses");

m.def("incremental_mapping",
static_cast<std::map<size_t, Reconstruction> (*)(const py::object,
const py::object,
const py::object,
const int,
const int)>(
const int,
const py::object)>(
&incremental_mapping),
py::arg("database_path"),
py::arg("image_path"),
py::arg("output_path"),
py::arg("num_threads") = mapper_options.num_threads,
py::arg("min_num_matches") = mapper_options.min_num_matches,
py::arg("input_path") = py::str(""),
"Triangulate 3D points from known poses");
}