From 0b907d088dc2349b8b8785df723991171ca24b3e Mon Sep 17 00:00:00 2001 From: Leonid Beynenson Date: Thu, 1 Dec 2011 13:35:07 +0000 Subject: [PATCH] =?UTF-8?q?Made=20changes=20in=20BundleAdjusterBase=20clas?= =?UTF-8?q?s=20to=20pass=20a=20termination=20criteria=20to=20the=20Levenbe?= =?UTF-8?q?rg=E2=80=93Marquardt=20algorithm.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../include/opencv2/stitching/detail/motion_estimators.hpp | 7 +++++++ modules/stitching/src/motion_estimators.cpp | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/stitching/include/opencv2/stitching/detail/motion_estimators.hpp b/modules/stitching/include/opencv2/stitching/detail/motion_estimators.hpp index 81fff1f699..b199f66f1e 100644 --- a/modules/stitching/include/opencv2/stitching/detail/motion_estimators.hpp +++ b/modules/stitching/include/opencv2/stitching/detail/motion_estimators.hpp @@ -93,6 +93,9 @@ public: double confThresh() const { return conf_thresh_; } void setConfThresh(double conf_thresh) { conf_thresh_ = conf_thresh; } + CvTermCriteria termCriteria() { return term_criteria_; } + void setTermCriteria(const CvTermCriteria& term_criteria) { term_criteria_ = term_criteria; } + protected: BundleAdjusterBase(int num_params_per_cam, int num_errs_per_measurement) : num_params_per_cam_(num_params_per_cam), @@ -100,6 +103,7 @@ protected: { setRefinementMask(Mat::ones(3, 3, CV_8U)); setConfThresh(1.); + setTermCriteria(cvTermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 1000, DBL_EPSILON)); } // Runs bundle adjustment @@ -127,6 +131,9 @@ protected: // Threshold to filter out poorly matched image pairs double conf_thresh_; + //Levenberg–Marquardt algorithm termination criteria + CvTermCriteria term_criteria_; + // Camera parameters matrix (CV_64F) Mat cam_params_; diff --git a/modules/stitching/src/motion_estimators.cpp b/modules/stitching/src/motion_estimators.cpp index c302bba589..2abb7dcc82 100644 --- a/modules/stitching/src/motion_estimators.cpp +++ b/modules/stitching/src/motion_estimators.cpp @@ -188,7 +188,7 @@ void BundleAdjusterBase::estimate(const vector &features, CvLevMarq solver(num_images_ * num_params_per_cam_, total_num_matches_ * num_errs_per_measurement_, - cvTermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 1000, DBL_EPSILON)); + term_criteria_); Mat err, jac; CvMat matParams = cam_params_;