added leaveBiggestComponent function into opencv_stitching

This commit is contained in:
Alexey Spizhevoy
2011-05-18 07:11:45 +00:00
parent f3b45af876
commit 21d89cc420
5 changed files with 109 additions and 45 deletions

View File

@@ -123,22 +123,19 @@ void SurfFeaturesFinder::find(const vector<Mat> &images, vector<ImageFeatures> &
//////////////////////////////////////////////////////////////////////////////
MatchesInfo::MatchesInfo() : src_img_idx(-1), dst_img_idx(-1), num_inliers(0) {}
MatchesInfo::MatchesInfo(const MatchesInfo &other)
{
*this = other;
}
MatchesInfo::MatchesInfo() : src_img_idx(-1), dst_img_idx(-1), num_inliers(0), confidence(0) {}
MatchesInfo::MatchesInfo(const MatchesInfo &other) { *this = other; }
const MatchesInfo& MatchesInfo::operator =(const MatchesInfo &other)
{
src_img_idx = other.src_img_idx;
dst_img_idx = other.dst_img_idx;
matches = other.matches;
inliers_mask = other.inliers_mask;
num_inliers = other.num_inliers;
H = other.H.clone();
confidence = other.confidence;
return *this;
}
@@ -303,14 +300,14 @@ void BestOf2NearestMatcher::match(const Mat &img1, const ImageFeatures &features
Mat dst_points(1, matches_info.matches.size(), CV_32FC2);
for (size_t i = 0; i < matches_info.matches.size(); ++i)
{
const DMatch& r = matches_info.matches[i];
const DMatch& m = matches_info.matches[i];
Point2f p = features1.keypoints[r.queryIdx].pt;
Point2f p = features1.keypoints[m.queryIdx].pt;
p.x -= img1.cols * 0.5f;
p.y -= img1.rows * 0.5f;
src_points.at<Point2f>(0, i) = p;
p = features2.keypoints[r.trainIdx].pt;
p = features2.keypoints[m.trainIdx].pt;
p.x -= img2.cols * 0.5f;
p.y -= img2.rows * 0.5f;
dst_points.at<Point2f>(0, i) = p;
@@ -325,6 +322,8 @@ void BestOf2NearestMatcher::match(const Mat &img1, const ImageFeatures &features
if (matches_info.inliers_mask[i])
matches_info.num_inliers++;
matches_info.confidence = matches_info.num_inliers / (8 + 0.3*matches_info.matches.size());
// Check if we should try to refine motion
if (matches_info.num_inliers < num_matches_thresh2_)
return;
@@ -338,14 +337,14 @@ void BestOf2NearestMatcher::match(const Mat &img1, const ImageFeatures &features
if (!matches_info.inliers_mask[i])
continue;
const DMatch& r = matches_info.matches[i];
const DMatch& m = matches_info.matches[i];
Point2f p = features1.keypoints[r.queryIdx].pt;
Point2f p = features1.keypoints[m.queryIdx].pt;
p.x -= img1.cols * 0.5f;
p.y -= img2.rows * 0.5f;
src_points.at<Point2f>(0, inlier_idx) = p;
p = features2.keypoints[r.trainIdx].pt;
p = features2.keypoints[m.trainIdx].pt;
p.x -= img2.cols * 0.5f;
p.y -= img2.rows * 0.5f;
dst_points.at<Point2f>(0, inlier_idx) = p;