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

Function testHomographyFitting

examples/cpp_example.cpp:970–1124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

968}
969
970void testHomographyFitting(
971 const std::string& source_path_,
972 const std::string& destination_path_,
973 const std::string& out_correspondence_path_,
974 const std::string& in_correspondence_path_,
975 const std::string& output_match_image_path_,
976 const double confidence_,
977 const double inlier_outlier_threshold_,
978 const double spatial_coherence_weight_,
979 const size_t cell_number_in_neighborhood_graph_,
980 const int fps_,
981 const double minimum_inlier_ratio_for_sprt_) // An assumption about the minimum inlier ratio used for the SPRT test
982{
983 // Read the images
984 cv::Mat source_image = cv::imread(source_path_); // The source image
985 cv::Mat destination_image = cv::imread(destination_path_); // The destination image
986
987 if (source_image.empty()) // Check if the source image is loaded successfully
988 {
989 printf("An error occured while loading image '%s'\n",
990 source_path_.c_str());
991 return;
992 }
993
994 if (destination_image.empty()) // Check if the destination image is loaded successfully
995 {
996 printf("An error occured while loading image '%s'\n",
997 destination_path_.c_str());
998 return;
999 }
1000
1001 // Detect or load point correspondences using AKAZE
1002 cv::Mat points;
1003 utils::detectFeatures(
1004 in_correspondence_path_, // The path where the correspondences are read from or saved to.
1005 source_image, // The source image
1006 destination_image, // The destination image
1007 points); // The detected point correspondences. Each row is of format "x1 y1 x2 y2"
1008
1009 // Initialize the neighborhood used in Graph-cut RANSAC and, perhaps,
1010 // in the sampler if NAPSAC or Progressive-NAPSAC sampling is applied.
1011 std::chrono::time_point<std::chrono::system_clock> start, end; // Variables for time measurement
1012 start = std::chrono::system_clock::now(); // The starting time of the neighborhood calculation
1013 neighborhood::GridNeighborhoodGraph<4> neighborhood(&points,
1014 { source_image.cols / static_cast<double>(cell_number_in_neighborhood_graph_),
1015 source_image.rows / static_cast<double>(cell_number_in_neighborhood_graph_),
1016 destination_image.cols / static_cast<double>(cell_number_in_neighborhood_graph_),
1017 destination_image.rows / static_cast<double>(cell_number_in_neighborhood_graph_) },
1018 cell_number_in_neighborhood_graph_);
1019 end = std::chrono::system_clock::now(); // The end time of the neighborhood calculation
1020 std::chrono::duration<double> elapsed_seconds = end - start; // The elapsed time in seconds
1021 printf("Neighborhood calculation time = %f secs\n", elapsed_seconds.count());
1022
1023 // Checking if the neighborhood graph is initialized successfully.
1024 if (!neighborhood.isInitialized())
1025 {
1026 fprintf(stderr, "The neighborhood graph is not initialized successfully.\n");
1027 return;

Callers 1

mainFunction · 0.85

Calls 8

detectFeaturesFunction · 0.85
drawMatchesFunction · 0.85
savePointsToFileFunction · 0.85
showImageFunction · 0.85
setFPSMethod · 0.80
isInitializedMethod · 0.45
sampleSizeMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected