mirror of
https://github.com/opencv/opencv.git
synced 2024-11-29 05:29:54 +08:00
Added matching mask into pairwise matcher from stitching module
This commit is contained in:
parent
551113292b
commit
b053a3b486
@ -133,7 +133,9 @@ public:
|
||||
|
||||
void operator ()(const ImageFeatures &features1, const ImageFeatures &features2,
|
||||
MatchesInfo& matches_info) { match(features1, features2, matches_info); }
|
||||
void operator ()(const std::vector<ImageFeatures> &features, std::vector<MatchesInfo> &pairwise_matches);
|
||||
|
||||
void operator ()(const std::vector<ImageFeatures> &features, std::vector<MatchesInfo> &pairwise_matches,
|
||||
const cv::Mat &mask = cv::Mat());
|
||||
|
||||
bool isThreadSafe() const { return is_thread_safe_; }
|
||||
|
||||
|
@ -95,6 +95,13 @@ public:
|
||||
void setFeaturesMatcher(Ptr<detail::FeaturesMatcher> features_matcher)
|
||||
{ features_matcher_ = features_matcher; }
|
||||
|
||||
const cv::Mat& matchingMask() const { return matching_mask_; }
|
||||
void setMatchingMask(const cv::Mat &mask)
|
||||
{
|
||||
CV_Assert(mask.type() == CV_8U && mask.cols == mask.rows);
|
||||
matching_mask_ = mask.clone();
|
||||
}
|
||||
|
||||
Ptr<detail::BundleAdjusterBase> bundleAdjuster() { return bundle_adjuster_; }
|
||||
const Ptr<detail::BundleAdjusterBase> bundleAdjuster() const { return bundle_adjuster_; }
|
||||
void setBundleAdjuster(Ptr<detail::BundleAdjusterBase> bundle_adjuster)
|
||||
@ -130,6 +137,7 @@ private:
|
||||
double conf_thresh_;
|
||||
Ptr<detail::FeaturesFinder> features_finder_;
|
||||
Ptr<detail::FeaturesMatcher> features_matcher_;
|
||||
cv::Mat matching_mask_;
|
||||
Ptr<detail::BundleAdjusterBase> bundle_adjuster_;
|
||||
bool do_wave_correct_;
|
||||
detail::WaveCorrectKind wave_correct_kind_;
|
||||
|
@ -45,6 +45,7 @@
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
using namespace cv::detail;
|
||||
|
||||
#ifndef ANDROID
|
||||
using namespace cv::gpu;
|
||||
#endif
|
||||
@ -340,14 +341,20 @@ const MatchesInfo& MatchesInfo::operator =(const MatchesInfo &other)
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void FeaturesMatcher::operator ()(const vector<ImageFeatures> &features, vector<MatchesInfo> &pairwise_matches)
|
||||
void FeaturesMatcher::operator ()(const vector<ImageFeatures> &features, vector<MatchesInfo> &pairwise_matches,
|
||||
const Mat &mask)
|
||||
{
|
||||
const int num_images = static_cast<int>(features.size());
|
||||
|
||||
CV_Assert(mask.empty() || (mask.type() == CV_8U && mask.cols == num_images && mask.rows));
|
||||
Mat_<uchar> mask_(mask);
|
||||
if (mask_.empty())
|
||||
mask_ = Mat::ones(num_images, num_images, CV_8U);
|
||||
|
||||
vector<pair<int,int> > near_pairs;
|
||||
for (int i = 0; i < num_images - 1; ++i)
|
||||
for (int j = i + 1; j < num_images; ++j)
|
||||
if (features[i].keypoints.size() > 0 && features[j].keypoints.size() > 0)
|
||||
if (features[i].keypoints.size() > 0 && features[j].keypoints.size() > 0 && mask_(i, j))
|
||||
near_pairs.push_back(make_pair(i, j));
|
||||
|
||||
pairwise_matches.resize(num_images * num_images);
|
||||
|
@ -165,7 +165,7 @@ Stitcher::Status Stitcher::matchImages()
|
||||
|
||||
LOG("Pairwise matching");
|
||||
t = getTickCount();
|
||||
(*features_matcher_)(features_, pairwise_matches_);
|
||||
(*features_matcher_)(features_, pairwise_matches_, matching_mask_);
|
||||
features_matcher_->collectGarbage();
|
||||
LOGLN("Pairwise matching, time: " << ((getTickCount() - t) / getTickFrequency()) << " sec");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user