<< "Usage: opencv_stitching img1 img2 [...imgN]\n" \r
<< "\t[--matchconf <0.0-1.0>]\n"\r
<< "\t[--ba (ray|focal_ray)]\n"\r
+ << "\t[--ba_thresh <float>]\n"\r
//<< "\t[--wavecorrect (no|yes)]\n"\r
<< "\t[--warp (plane|cylindrical|spherical)]\n" \r
<< "\t[--seam (no|voronoi|graphcut)]\n" \r
vector<Mat> images;\r
string result_name = "result.png";\r
int ba_space = BundleAdjuster::RAY_SPACE;\r
+ float ba_thresh = 1.f;\r
bool wave_correct = false;\r
int warp_type = Warper::SPHERICAL;\r
bool user_match_conf = false;\r
else if (string(argv[i]) == "--matchconf")\r
{\r
user_match_conf = true;\r
- match_conf = static_cast<float>(atof(string(argv[i + 1]).c_str()));\r
+ match_conf = static_cast<float>(atof(argv[i + 1]));\r
i++;\r
}\r
else if (string(argv[i]) == "--ba")\r
}\r
i++;\r
}\r
+ else if (string(argv[i]) == "--ba_thresh")\r
+ {\r
+ ba_thresh = static_cast<float>(atof(argv[i + 1]));\r
+ i++;\r
+ }\r
//else if (string(argv[i]) == "--wavecorrect")\r
//{\r
// if (string(argv[i + 1]) == "no")\r
}\r
\r
LOGLN("Bundle adjustment...");\r
- BundleAdjuster adjuster(ba_space);\r
+ BundleAdjuster adjuster(ba_space, ba_thresh);\r
adjuster(images, features, pairwise_matches, cameras);\r
\r
if (wave_correct)\r
edges_.clear();
for (int i = 0; i < num_images_ - 1; ++i)
+ {
for (int j = i + 1; j < num_images_; ++j)
- edges_.push_back(make_pair(i, j));
+ {
+ int pair_idx = i * num_images_ + j;\r
+ const MatchesInfo& mi = pairwise_matches_[pair_idx];\r
+ float ni = static_cast<float>(mi.num_inliers);\r
+ float nf = static_cast<float>(mi.matches.size());\r
+ if (ni / (8.f + 0.3f * nf) > dist_thresh_)\r
+ edges_.push_back(make_pair(i, j));
+ }
+ }
total_num_matches_ = 0;
for (size_t i = 0; i < edges_.size(); ++i)
if (_err)
{
calcError(err_);
- //LOGLN("Error: " << sqrt(err_.dot(err_)));
+ LOGLN("Error: " << sqrt(err_.dot(err_)));
count++;
CvMat matErr = err_;
cvCopy( &matErr, _err );
public:
enum { RAY_SPACE, FOCAL_RAY_SPACE };
- BundleAdjuster(int cost_space = FOCAL_RAY_SPACE) : cost_space_(cost_space) {}
+ BundleAdjuster(int cost_space = FOCAL_RAY_SPACE, float dist_thresh = 1.f)
+ : cost_space_(cost_space), dist_thresh_(dist_thresh) {}
private:
void estimate(const std::vector<cv::Mat> &images, const std::vector<ImageFeatures> &features,
std::vector<std::pair<int,int> > edges_;
int cost_space_;
+ float dist_thresh_;
cv::Mat err_, err1_, err2_;
cv::Mat J_;
};