35 #include <opencv2/imgproc/imgproc.hpp> 36 #include <opencv2/highgui/highgui.hpp> 37 #include <opencv2/calib3d/calib3d.hpp> 44 const cv::Mat points2,
45 cv::Mat& fundamental_matrix,
51 std::vector<uint32_t> indices;
62 const cv::Mat points2,
63 cv::Mat& fundamental_matrix,
66 std::vector<uint32_t>& indices,
70 std::vector<uchar> status;
71 fundamental_matrix = cv::findFundamentalMat(
80 for (
unsigned int i = 0; i < status.size(); i++)
88 indices.resize(inliers);
92 inliers1 = cv::Mat(cv::Size(1, inliers), CV_32FC2);
93 inliers2 = cv::Mat(cv::Size(1, inliers), CV_32FC2);
96 for (
unsigned int i = 0; i < status.size(); i++)
100 inliers1.at<cv::Vec2f>(0, index) = points1.at<cv::Vec2f>(0, i);
101 inliers2.at<cv::Vec2f>(0, index) = points2.at<cv::Vec2f>(0, i);
110 const std::vector<cv::KeyPoint>& kp2,
111 const std::vector<cv::DMatch>& matches,
117 kp1_out.create(cv::Size(1, matches.size()), CV_32FC2);
118 kp2_out.create(cv::Size(1, matches.size()), CV_32FC2);
120 for (
unsigned int i = 0; i < matches.size(); i++)
122 kp1_out.at<cv::Vec2f>(0, i) = kp1[matches[i].queryIdx].pt;
123 kp2_out.at<cv::Vec2f>(0, i) = kp2[matches[i].trainIdx].pt;
void GetFundamentalInliers(const cv::Mat points1, const cv::Mat points2, cv::Mat &fundamental_matrix, cv::Mat &inliers1, cv::Mat &inliers2, double max_distance=1.0, double confidence=0.99)
Computes the fundamental matrix for a set of matching points in two different images. The method also returns the inlier keypoints for both frames.
void ConvertMatches(const std::vector< cv::KeyPoint > &kp1, const std::vector< cv::KeyPoint > &kp2, const std::vector< cv::DMatch > &matches, cv::Mat &kp1_out, cv::Mat &kp2_out)
Converts keypoints and matches into two cv::Mats in which the the matching keypoints from kp1 and kp2...