From 3928dd9d992c34265e90cffdb84928dc656293ab Mon Sep 17 00:00:00 2001 From: Alexey Spizhevoy Date: Fri, 6 May 2011 05:14:07 +0000 Subject: [PATCH] added --ba_thresh key into opencv_stitching CLI --- modules/stitching/main.cpp | 11 +++++++++-- modules/stitching/motion_estimators.cpp | 13 +++++++++++-- modules/stitching/motion_estimators.hpp | 4 +++- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/modules/stitching/main.cpp b/modules/stitching/main.cpp index 5f8fce310..9468edb16 100644 --- a/modules/stitching/main.cpp +++ b/modules/stitching/main.cpp @@ -15,6 +15,7 @@ void printUsage() << "Usage: opencv_stitching img1 img2 [...imgN]\n" << "\t[--matchconf <0.0-1.0>]\n" << "\t[--ba (ray|focal_ray)]\n" + << "\t[--ba_thresh ]\n" //<< "\t[--wavecorrect (no|yes)]\n" << "\t[--warp (plane|cylindrical|spherical)]\n" << "\t[--seam (no|voronoi|graphcut)]\n" @@ -29,6 +30,7 @@ int main(int argc, char* argv[]) vector images; string result_name = "result.png"; int ba_space = BundleAdjuster::RAY_SPACE; + float ba_thresh = 1.f; bool wave_correct = false; int warp_type = Warper::SPHERICAL; bool user_match_conf = false; @@ -52,7 +54,7 @@ int main(int argc, char* argv[]) else if (string(argv[i]) == "--matchconf") { user_match_conf = true; - match_conf = static_cast(atof(string(argv[i + 1]).c_str())); + match_conf = static_cast(atof(argv[i + 1])); i++; } else if (string(argv[i]) == "--ba") @@ -68,6 +70,11 @@ int main(int argc, char* argv[]) } i++; } + else if (string(argv[i]) == "--ba_thresh") + { + ba_thresh = static_cast(atof(argv[i + 1])); + i++; + } //else if (string(argv[i]) == "--wavecorrect") //{ // if (string(argv[i + 1]) == "no") @@ -176,7 +183,7 @@ int main(int argc, char* argv[]) } LOGLN("Bundle adjustment..."); - BundleAdjuster adjuster(ba_space); + BundleAdjuster adjuster(ba_space, ba_thresh); adjuster(images, features, pairwise_matches, cameras); if (wave_correct) diff --git a/modules/stitching/motion_estimators.cpp b/modules/stitching/motion_estimators.cpp index 952077ae9..2d2f02da0 100644 --- a/modules/stitching/motion_estimators.cpp +++ b/modules/stitching/motion_estimators.cpp @@ -491,8 +491,17 @@ void BundleAdjuster::estimate(const vector &images, const vector(mi.num_inliers); + float nf = static_cast(mi.matches.size()); + if (ni / (8.f + 0.3f * nf) > dist_thresh_) + edges_.push_back(make_pair(i, j)); + } + } total_num_matches_ = 0; for (size_t i = 0; i < edges_.size(); ++i) @@ -528,7 +537,7 @@ void BundleAdjuster::estimate(const vector &images, const vector &images, const std::vector &features, @@ -143,6 +144,7 @@ private: std::vector > edges_; int cost_space_; + float dist_thresh_; cv::Mat err_, err1_, err2_; cv::Mat J_; };