MCPcopy Create free account
hub / github.com/danini/magsac / testFundamentalMatrixFitting

Function testFundamentalMatrixFitting

examples/cpp_example.cpp:533–696  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

531}
532
533void testFundamentalMatrixFitting(
534 double ransac_confidence_,
535 double maximum_threshold_,
536 std::string test_scene_,
537 bool use_magsac_plus_plus_,
538 bool draw_results_,
539 double drawing_threshold_)
540{
541 std::cout << "Processed scene = '" << test_scene_ << "'.";
542
543 // Load the images of the current test scene
544 cv::Mat image1 = cv::imread("../data/fundamental_matrix/" + test_scene_ + "A.png");
545 cv::Mat image2 = cv::imread("../data/fundamental_matrix/" + test_scene_ + "B.png");
546 if (image1.cols == 0)
547 {
548 image1 = cv::imread("../data/fundamental_matrix/" + test_scene_ + "A.jpg");
549 image2 = cv::imread("../data/fundamental_matrix/" + test_scene_ + "B.jpg");
550 }
551
552 if (image1.cols == 0)
553 {
554 std::cerr << "A problem occured when loading the images for test scene " << test_scene_ << ".";
555 return;
556 }
557
558 cv::Mat points; // The point correspondences, each is of format x1 y1 x2 y2
559 std::vector<int> ground_truth_labels; // The ground truth labeling provided in the dataset
560
561 // A function loading the points from files
562 readAnnotatedPoints("../data/fundamental_matrix/" + test_scene_ + "_pts.txt",
563 points,
564 ground_truth_labels);
565
566 // The number of points in the datasets
567 const size_t N = points.rows; // The number of points in the scene
568
569 if (N == 0) // If there are no points, return
570 {
571 std::cerr << "A problem occured when loading the annotated points for test scene " << test_scene_ << ".";
572 return;
573 }
574
575 magsac::utils::DefaultFundamentalMatrixEstimator estimator(maximum_threshold_); // The robust homography estimator class containing the function for the fitting and residual calculation
576 gcransac::FundamentalMatrix model; // The estimated model
577
578 // In this used datasets, the manually selected inliers are not all inliers but a subset of them.
579 // Therefore, the manually selected inliers are augmented as follows:
580 // (i) First, the implied model is estimated from the manually selected inliers.
581 // (ii) Second, the inliers of the ground truth model are selected.
582 std::vector<int> refined_labels = ground_truth_labels;
583 refineManualLabeling<gcransac::FundamentalMatrix, magsac::utils::DefaultFundamentalMatrixEstimator>(
584 points,
585 refined_labels,
586 estimator,
587 0.35); // Threshold value from the LO*-RANSAC paper
588
589 // Select the inliers from the labeling
590 std::vector<int> ground_truth_inliers = getSubsetFromLabeling(ground_truth_labels, 1),

Callers 1

runTestFunction · 0.85

Calls 7

readAnnotatedPointsFunction · 0.85
getSubsetFromLabelingFunction · 0.85
showImageFunction · 0.85
setMaximumThresholdMethod · 0.80
setIterationLimitMethod · 0.80
runMethod · 0.80
selectInliersMethod · 0.80

Tested by

no test coverage detected