21RansacFundamental::RansacFundamental (
Options const& options)
32 <<
" iterations, threshold " << this->opts.
threshold
33 <<
"..." << std::endl;
36 std::vector<int> inliers;
37 inliers.reserve(matches.size());
38 for (
int iteration = 0; iteration < this->opts.
max_iterations; ++iteration)
41 this->estimate_8_point(matches, &fundamental);
42 this->find_inliers(matches, fundamental, &inliers);
43 if (inliers.size() > result->
inliers.size())
47 std::cout <<
"RANSAC-F: Iteration " << iteration
48 <<
", inliers " << inliers.size() <<
" ("
49 << (100.0 * inliers.size() / matches.size())
55 inliers.reserve(matches.size());
64 if (matches.size() < 8)
65 throw std::invalid_argument(
"At least 8 matches required");
72 while (result.size() < 8)
76 std::set<int>::const_iterator iter = result.
begin();
77 for (
int i = 0; i < 8; ++i, ++iter)
80 pset1(0, i) = match.
p1[0];
81 pset1(1, i) = match.
p1[1];
83 pset2(0, i) = match.
p2[0];
84 pset2(1, i) = match.
p2[1];
99 for (std::size_t i = 0; i < matches.size(); ++i)
102 if (error < squared_thres)
103 result->push_back(i);
void estimate(Correspondences2D2D const &matches, Result *result)
void enforce_fundamental_constraints(FundamentalMatrix *matrix)
Constraints the given matrix to have TWO NON-ZERO eigenvalues.
math::Matrix< double, 3, 3 > FundamentalMatrix
std::vector< Correspondence2D2D > Correspondences2D2D
bool fundamental_8_point(Eight2DPoints const &points_view_1, Eight2DPoints const &points_view_2, FundamentalMatrix *result)
Algorithm to compute the fundamental or essential matrix from 8 image correspondences.
double sampson_distance(FundamentalMatrix const &F, Correspondence2D2D const &m)
Computes the Sampson distance for an image correspondence given the fundamental matrix between two vi...
void swap(mve::Image< T > &a, mve::Image< T > &b)
Specialization of std::swap for efficient image swapping.
int rand_int(void)
Returns a random number in [0, 2^31].
#define SFM_NAMESPACE_END
#define SFM_NAMESPACE_BEGIN
Two image coordinates which correspond to each other in terms of observing the same point in the scen...
bool verbose_output
Produce status messages on the console.
double threshold
Threshold used to determine inliers.
int max_iterations
The number of RANSAC iterations.
FundamentalMatrix fundamental
The resulting fundamental matrix which led to the inliers.
std::vector< int > inliers
The indices of inliers in the correspondences which led to the homography matrix.