41 #include <glog/logging.h>
49 Matrix3d& fundamental_matrix)
const {
54 if (matched_features.size() < 8) {
55 VLOG(1) <<
"Cannot use the eight-point algorithm with less than 8 feature "
62 A.resize(matched_features.size(), 9);
65 Matrix3d T1(MatrixXd::Identity(3, 3));
66 Matrix3d T2(MatrixXd::Identity(3, 3));
73 for (
size_t ii = 0; ii < matched_features.size(); ++ii) {
74 double u1 = matched_features[ii].feature1_.u_;
75 double v1 = matched_features[ii].feature1_.v_;
76 double u2 = matched_features[ii].feature2_.u_;
77 double v2 = matched_features[ii].feature2_.v_;
80 u1 = T1(0, 0) * u1 + T1(0, 2);
81 v1 = T1(1, 1) * v1 + T1(1, 2);
82 u2 = T2(0, 0) * u2 + T2(0, 2);
83 v2 = T2(1, 1) * v2 + T2(1, 2);
98 Eigen::JacobiSVD<Eigen::MatrixXd> svd;
99 svd.compute(A, Eigen::ComputeThinU | Eigen::ComputeFullV);
100 if (!svd.computeV()) {
101 VLOG(1) <<
"Failed to compute a singular value decomposition of A matrix.";
106 const VectorXd f_vec = svd.matrixV().col(8);
109 fundamental_matrix.row(0) = f_vec.topRows(3).transpose();
110 fundamental_matrix.row(1) = f_vec.middleRows(3, 3).transpose();
111 fundamental_matrix.row(2) = f_vec.bottomRows(3).transpose();
117 svd.compute(fundamental_matrix, Eigen::ComputeFullU | Eigen::ComputeFullV);
118 svd.compute(fundamental_matrix);
119 if (!svd.computeU() || !svd.computeV()) {
120 VLOG(1) <<
"Failed to compute a singular value decomposition of "
121 "fundamental matrix.";
127 MatrixXd S_deficient(MatrixXd::Zero(3, 3));
128 S_deficient(0, 0) = svd.singularValues()(0);
129 S_deficient(1, 1) = svd.singularValues()(1);
130 fundamental_matrix = svd.matrixU() * S_deficient * svd.matrixV().transpose();
136 fundamental_matrix = T2.transpose() * fundamental_matrix * T1;
Matrix3d ComputeNormalization(const FeatureMatchList &matched_features, bool use_feature_set1)
virtual bool ComputeFundamentalMatrix(const FeatureMatchList &matched_features, Matrix3d &fundamental_matrix) const
std::vector< FeatureMatch > FeatureMatchList
bool enforce_fundamental_matrix_rank_deficiency
FundamentalMatrixSolverOptions options_