8000 Add new model_transformer command by anmatako · Pull Request #1178 · colmap/colmap · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add new model_transformer command #1178

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

Merged
merged 15 commits into from
Apr 8, 2021
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions src/exe/colmap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ int main(int argc, char** argv) {
commands.emplace_back("model_orientation_aligner",
&RunModelOrientationAligner);
commands.emplace_back("model_splitter", &RunModelSplitter);
commands.emplace_back("model_transformer", &RunModelTransformer);
commands.emplace_back("patch_match_stereo", &RunPatchMatchStereo);
commands.emplace_back("point_filtering", &RunPointFiltering);
commands.emplace_back("point_triangulator", &RunPointTriangulator);
Expand Down
48 changes: 48 additions & 0 deletions src/exe/model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -873,4 +873,52 @@ int RunModelSplitter(int argc, char** argv) {
return EXIT_SUCCESS;
}

int RunModelTransformer(int argc, char** argv) {
std::string input_path;
std::string output_path;
std::string transform_path;
bool is_inverse = false;

OptionManager options;
options.AddRequiredOption("input_path", &input_path);
options.AddRequiredOption("output_path", &output_path);
options.AddRequiredOption("transform_path", &transform_path);
options.AddDefaultOption("is_inverse", &is_inverse);
options.Parse(argc, argv);

std::cout << "Reading points input: " << input_path << std::endl;
Reconstruction recon;
bool is_dense = false;
if (HasFileExtension(input_path, ".ply")) {
is_dense = true;
recon.ImportPLY(input_path);
} else if (ExistsDir(input_path)) {
recon.Read(input_path);
} else {
std::cerr << "Invalid model input; not a PLY file or sparse reconstruction "
"directory."
<< std::endl;
return EXIT_FAILURE;
}

std::cout << "Reading transform input: " << transform_path << std::endl;
SimilarityTransform3 tform = SimilarityTransform3::FromFile(transform_path);
if (is_inverse) {
tform = tform.Inverse();
}

std::cout << "Applying transform to recon with " << recon.NumPoints3D()
<< " points" << std::endl;
recon.Transform(tform);

std::cout << "Writing output: " << output_path << std::endl;
if (is_dense) {
recon.ExportPLY(output_path);
} else {
recon.Write(output_path);
}

return EXIT_SUCCESS;
}

} // namespace colmap
1 change: 1 addition & 0 deletions src/exe/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ int RunModelCropper(int argc, char** argv);
int RunModelMerger(int argc, char** argv);
int RunModelOrientationAligner(int argc, char** argv);
int RunModelSplitter(int argc, char** argv);
int RunModelTransformer(int argc, char** argv);

} // namespace colmap
0