| 346 | } |
| 347 | |
| 348 | void SolveProblem(const char* filename) { |
| 349 | BALProblem bal_problem(filename, CERES_GET_FLAG(FLAGS_use_quaternions)); |
| 350 | |
| 351 | if (!CERES_GET_FLAG(FLAGS_initial_ply).empty()) { |
| 352 | bal_problem.WriteToPLYFile(CERES_GET_FLAG(FLAGS_initial_ply)); |
| 353 | } |
| 354 | |
| 355 | Problem problem; |
| 356 | |
| 357 | srand(CERES_GET_FLAG(FLAGS_random_seed)); |
| 358 | bal_problem.Normalize(); |
| 359 | bal_problem.Perturb(CERES_GET_FLAG(FLAGS_rotation_sigma), |
| 360 | CERES_GET_FLAG(FLAGS_translation_sigma), |
| 361 | CERES_GET_FLAG(FLAGS_point_sigma)); |
| 362 | |
| 363 | BuildProblem(&bal_problem, &problem); |
| 364 | Solver::Options options; |
| 365 | SetSolverOptionsFromFlags(&bal_problem, &options); |
| 366 | options.gradient_tolerance = 1e-16; |
| 367 | options.function_tolerance = 1e-16; |
| 368 | options.parameter_tolerance = 1e-16; |
| 369 | Solver::Summary summary; |
| 370 | Solve(options, &problem, &summary); |
| 371 | std::cout << summary.FullReport() << "\n"; |
| 372 | |
| 373 | if (!CERES_GET_FLAG(FLAGS_final_ply).empty()) { |
| 374 | bal_problem.WriteToPLYFile(CERES_GET_FLAG(FLAGS_final_ply)); |
| 375 | } |
| 376 | } |
| 377 | |
| 378 | } // namespace |
| 379 | } // namespace ceres::examples |
no test coverage detected