| 456 | } |
| 457 | |
| 458 | bool initializeScenePnP( |
| 459 | const std::string& scene_name_, |
| 460 | std::string& intrinsics_path_, |
| 461 | std::string& ground_truth_pose_path_, |
| 462 | std::string& points_path_, |
| 463 | std::string& inlier_image_points_path_, |
| 464 | const std::string root_directory_) // The root directory where the "results" and "data" folder are |
| 465 | { |
| 466 | // The directory to which the results will be saved |
| 467 | std::string results_dir = root_directory_ + "results"; |
| 468 | |
| 469 | // Create the task directory if it doesn't exist |
| 470 | if (stat(results_dir.c_str(), &info) != 0) // Check if exists |
| 471 | { |
| 472 | #ifdef _WIN32 // Create a directory on Windows |
| 473 | if (_mkdir(results_dir.c_str()) != 0) // Create it, if not |
| 474 | { |
| 475 | fprintf(stderr, "Error while creating folder 'results'\n"); |
| 476 | return false; |
| 477 | } |
| 478 | #else // Create a directory on Linux |
| 479 | if (mkdir(results_dir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == -1) |
| 480 | { |
| 481 | fprintf(stderr, "Error while creating a new folder in 'results'\n"); |
| 482 | return false; |
| 483 | } |
| 484 | #endif |
| 485 | } |
| 486 | |
| 487 | // The directory to which the results will be saved |
| 488 | std::string dir = root_directory_ + "results/" + scene_name_; |
| 489 | |
| 490 | // Create the task directory if it doesn't exist |
| 491 | if (stat(dir.c_str(), &info) != 0) // Check if exists |
| 492 | { |
| 493 | #ifdef _WIN32 // Create a directory on Windows |
| 494 | if (_mkdir(dir.c_str()) != 0) // Create it, if not |
| 495 | { |
| 496 | fprintf(stderr, "Error while creating a new folder in 'results'\n"); |
| 497 | return false; |
| 498 | } |
| 499 | #else // Create a directory on Linux |
| 500 | if (mkdir(dir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == -1) |
| 501 | { |
| 502 | fprintf(stderr, "Error while creating a new folder in 'results'\n"); |
| 503 | return false; |
| 504 | } |
| 505 | #endif |
| 506 | } |
| 507 | |
| 508 | // The path where the intrinsics camera matrix of the source camera can be found |
| 509 | intrinsics_path_ = |
| 510 | root_directory_ + "data/" + scene_name_ + "/" + scene_name_ + ".K"; |
| 511 | // The path where the ground truth pose can be found |
| 512 | ground_truth_pose_path_ = |
| 513 | root_directory_ + "data/" + scene_name_ + "/" + scene_name_ + "_gt.txt"; |
| 514 | // The path where the 3D point cloud can be found |
| 515 | points_path_ = |