MCPcopy Create free account
hub / github.com/danini/graph-cut-ransac / initializeScene

Function initializeScene

examples/cpp_example.cpp:524–608  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

522}
523
524bool initializeScene(
525 const std::string& scene_name_, // The name of the scene
526 std::string& src_image_path_, // The path to the source image
527 std::string& dst_image_path_, // The path to the destination image
528 std::string& input_correspondence_path_, // The path to the correspondences
529 std::string& output_correspondence_path_, // The path where the found inliers should be saved
530 std::string& output_matched_image_path_, // The path where the matched image should be saved,
531 const std::string root_directory_) // The root directory where the "results" and "data" folder are
532{
533 // The directory to which the results will be saved
534 std::string results_dir = root_directory_ + "results";
535
536 // Create the task directory if it doesn't exist
537 if (stat(results_dir.c_str(), &info) != 0) // Check if exists
538 {
539#ifdef _WIN32 // Create a directory on Windows
540 if (_mkdir(results_dir.c_str()) != 0) // Create it, if not
541 {
542 fprintf(stderr, "Error while creating folder 'results'\n");
543 return false;
544 }
545#else // Create a directory on Linux
546 if (mkdir(results_dir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == -1)
547 {
548 fprintf(stderr, "Error while creating a new folder in 'results'\n");
549 return false;
550 }
551#endif
552 }
553
554 // The directory to which the results will be saved
555 std::string dir = root_directory_ + "results/" + scene_name_;
556
557 // Create the task directory if it doesn't exist
558 if (stat(dir.c_str(), &info) != 0) // Check if exists
559 {
560#ifdef _WIN32 // Create a directory on Windows
561 if (_mkdir(dir.c_str()) != 0) // Create it, if not
562 {
563 fprintf(stderr, "Error while creating a new folder in 'results'\n");
564 return false;
565 }
566#else // Create a directory on Linux
567 if (mkdir(dir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == -1)
568 {
569 fprintf(stderr, "Error while creating a new folder in 'results'\n");
570 return false;
571 }
572#endif
573 }
574
575 // The source image's path
576 src_image_path_ =
577 root_directory_ + "data/" + scene_name_ + "/" + scene_name_ + "1.jpg";
578 if (cv::imread(src_image_path_).empty())
579 src_image_path_ = root_directory_ + "data/" + scene_name_ + "/" + scene_name_ + "1.png";
580 if (cv::imread(src_image_path_).empty())
581 {

Callers 1

mainFunction · 0.85

Calls 1

statClass · 0.85

Tested by

no test coverage detected