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_;