MCPcopy Create free account
hub / github.com/colmap/colmap / RunModelCropper

Function RunModelCropper

src/colmap/exe/model.cc:686–762  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

684}
685
686int RunModelCropper(int argc, char** argv) {
687 Timer timer;
688 timer.Start();
689
690 std::filesystem::path input_path;
691 std::filesystem::path output_path;
692 std::string boundary;
693 std::filesystem::path gps_transform_path;
694 bool is_gps = false;
695
696 OptionManager options;
697 options.AddRequiredOption("input_path", &input_path);
698 options.AddRequiredOption("output_path", &output_path);
699 options.AddRequiredOption("boundary", &boundary);
700 options.AddDefaultOption("gps_transform_path", &gps_transform_path);
701 if (!options.Parse(argc, argv)) {
702 return EXIT_FAILURE;
703 }
704
705 if (!ExistsDir(input_path)) {
706 LOG(ERROR) << "`input_path` is not a directory";
707 return EXIT_FAILURE;
708 }
709
710 if (!ExistsDir(output_path)) {
711 LOG(ERROR) << "`output_path` is not a directory";
712 return EXIT_FAILURE;
713 }
714
715 std::vector<double> boundary_elements = CSVToVector<double>(boundary);
716 if (boundary_elements.size() != 2 && boundary_elements.size() != 6) {
717 LOG(ERROR) << "Invalid `boundary` - supported values are "
718 "'x1,y1,z1,x2,y2,z2' or 'p1,p2'.";
719 return EXIT_FAILURE;
720 }
721
722 Reconstruction reconstruction;
723 reconstruction.Read(input_path);
724
725 LOG_HEADING2("Calculating boundary coordinates");
726 Eigen::AlignedBox3d bounding_box;
727 if (boundary_elements.size() == 6) {
728 Sim3d tform;
729 if (!gps_transform_path.empty()) {
730 LOG_HEADING2("Reading model to ECEF transform");
731 is_gps = true;
732 tform = Inverse(Sim3d::FromFile(gps_transform_path));
733 }
734 bounding_box.min() =
735 is_gps ? TransformLatLonAltToModelCoords(tform,
736 boundary_elements[0],
737 boundary_elements[1],
738 boundary_elements[2])
739 : Eigen::Vector3d(boundary_elements[0],
740 boundary_elements[1],
741 boundary_elements[2]);
742 bounding_box.max() =
743 is_gps ? TransformLatLonAltToModelCoords(tform,

Callers

nothing calls this directly

Calls 15

ExistsDirFunction · 0.85
WriteBoundingBoxFunction · 0.85
AddRequiredOptionMethod · 0.80
AddDefaultOptionMethod · 0.80
ParseMethod · 0.80
sizeMethod · 0.80
emptyMethod · 0.80
ComputeBoundingBoxMethod · 0.80
CropMethod · 0.80
PrintMinutesMethod · 0.80
InverseFunction · 0.50

Tested by

no test coverage detected