/**
* This file is part of ORB-SLAM3
*
* Copyright (C) 2017-2021 Carlos Campos, Richard Elvira, Juan J. Gómez Rodríguez, José M.M. Montiel and Juan D. Tardós, University of Zaragoza.
* Copyright (C) 2014-2016 Raúl Mur-Artal, José M.M. Montiel and Juan D. Tardós, University of Zaragoza.
*
* ORB-SLAM3 is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ORB-SLAM3 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with ORB-SLAM3.
* If not, see .
*/
#ifndef TwoViewReconstruction_H
#define TwoViewReconstruction_H
#include
#include
#include
#include
namespace ORB_SLAM3
{
class TwoViewReconstruction
{
typedef std::pair Match;
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
// Fix the reference frame
TwoViewReconstruction(const Eigen::Matrix3f& k, float sigma = 1.0, int iterations = 200);
// Computes in parallel a fundamental matrix and a homography
// Selects a model and tries to recover the motion and the structure from motion
bool Reconstruct(const std::vector& vKeys1, const std::vector& vKeys2, const std::vector &vMatches12,
Sophus::SE3f &T21, std::vector &vP3D, std::vector &vbTriangulated);
private:
void FindHomography(std::vector &vbMatchesInliers, float &score, Eigen::Matrix3f &H21);
void FindFundamental(std::vector &vbInliers, float &score, Eigen::Matrix3f &F21);
Eigen::Matrix3f ComputeH21(const std::vector &vP1, const std::vector &vP2);
Eigen::Matrix3f ComputeF21(const std::vector &vP1, const std::vector &vP2);
float CheckHomography(const Eigen::Matrix3f &H21, const Eigen::Matrix3f &H12, std::vector &vbMatchesInliers, float sigma);
float CheckFundamental(const Eigen::Matrix3f &F21, std::vector &vbMatchesInliers, float sigma);
bool ReconstructF(std::vector &vbMatchesInliers, Eigen::Matrix3f &F21, Eigen::Matrix3f &K,
Sophus::SE3f &T21, std::vector &vP3D, std::vector &vbTriangulated, float minParallax, int minTriangulated);
bool ReconstructH(std::vector &vbMatchesInliers, Eigen::Matrix3f &H21, Eigen::Matrix3f &K,
Sophus::SE3f &T21, std::vector &vP3D,std:: vector &vbTriangulated, float minParallax, int minTriangulated);
void Normalize(const std::vector &vKeys, std::vector &vNormalizedPoints, Eigen::Matrix3f &T);
int CheckRT(const Eigen::Matrix3f &R, const Eigen::Vector3f &t, const std::vector &vKeys1, const std::vector &vKeys2,
const std::vector &vMatches12, std::vector &vbMatchesInliers,
const Eigen::Matrix3f &K, std::vector &vP3D, float th2, std::vector &vbGood, float ¶llax);
void DecomposeE(const Eigen::Matrix3f &E, Eigen::Matrix3f &R1, Eigen::Matrix3f &R2, Eigen::Vector3f &t);
// Keypoints from Reference Frame (Frame 1)
std::vector mvKeys1;
// Keypoints from Current Frame (Frame 2)
std::vector mvKeys2;
// Current Matches from Reference to Current
std::vector mvMatches12;
std::vector mvbMatched1;
// Calibration
Eigen::Matrix3f mK;
// Standard Deviation and Variance
float mSigma, mSigma2;
// Ransac max iterations
int mMaxIterations;
// Ransac sets
std::vector > mvSets;
};
} //namespace ORB_SLAM
#endif // TwoViewReconstruction_H