| 518 | } |
| 519 | |
| 520 | int RunModelComparer(int argc, char** argv) { |
| 521 | std::filesystem::path input_path1; |
| 522 | std::filesystem::path input_path2; |
| 523 | std::filesystem::path output_path; |
| 524 | std::string alignment_error = "reprojection"; |
| 525 | double min_inlier_observations = 0.3; |
| 526 | double max_reproj_error = 8.0; |
| 527 | double max_proj_center_error = 0.1; |
| 528 | |
| 529 | OptionManager options; |
| 530 | options.AddRequiredOption("input_path1", &input_path1); |
| 531 | options.AddRequiredOption("input_path2", &input_path2); |
| 532 | options.AddDefaultOption("output_path", &output_path); |
| 533 | options.AddDefaultOption( |
| 534 | "alignment_error", &alignment_error, "{reprojection, proj_center}"); |
| 535 | options.AddDefaultOption("min_inlier_observations", &min_inlier_observations); |
| 536 | options.AddDefaultOption("max_reproj_error", &max_reproj_error); |
| 537 | options.AddDefaultOption("max_proj_center_error", &max_proj_center_error); |
| 538 | if (!options.Parse(argc, argv)) { |
| 539 | return EXIT_FAILURE; |
| 540 | } |
| 541 | |
| 542 | if (!output_path.empty() && !ExistsDir(output_path)) { |
| 543 | LOG(ERROR) << "Provided output path is not a valid directory"; |
| 544 | return EXIT_FAILURE; |
| 545 | } |
| 546 | |
| 547 | Reconstruction reconstruction1; |
| 548 | reconstruction1.Read(input_path1); |
| 549 | Reconstruction reconstruction2; |
| 550 | reconstruction2.Read(input_path2); |
| 551 | std::vector<ImageAlignmentError> errors; |
| 552 | Sim3d rec2_from_rec1; |
| 553 | bool success = CompareModels(reconstruction1, |
| 554 | reconstruction2, |
| 555 | alignment_error, |
| 556 | min_inlier_observations, |
| 557 | max_reproj_error, |
| 558 | max_proj_center_error, |
| 559 | errors, |
| 560 | rec2_from_rec1); |
| 561 | if (!success) { |
| 562 | return EXIT_FAILURE; |
| 563 | } |
| 564 | if (!output_path.empty()) { |
| 565 | const auto errors_path = output_path / "errors.csv"; |
| 566 | WriteComparisonErrorsCSV(errors_path, errors); |
| 567 | const auto summary_path = output_path / "errors_summary.txt"; |
| 568 | std::ofstream file(summary_path, std::ios::trunc); |
| 569 | THROW_CHECK_FILE_OPEN(file, summary_path); |
| 570 | PrintComparisonSummary(file, errors); |
| 571 | } |
| 572 | return EXIT_SUCCESS; |
| 573 | } |
| 574 | |
| 575 | bool CompareModels(const Reconstruction& reconstruction1, |
| 576 | const Reconstruction& reconstruction2, |
nothing calls this directly
no test coverage detected