mirror of
https://github.com/opencv/opencv.git
synced 2024-11-24 11:10:21 +08:00
added --ba_thresh key into opencv_stitching CLI
This commit is contained in:
parent
e72c0ad661
commit
3928dd9d99
@ -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 <float>]\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<Mat> 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<float>(atof(string(argv[i + 1]).c_str()));
|
||||
match_conf = static_cast<float>(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<float>(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)
|
||||
|
@ -491,8 +491,17 @@ void BundleAdjuster::estimate(const vector<Mat> &images, const vector<ImageFeatu
|
||||
|
||||
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;
|
||||
const MatchesInfo& mi = pairwise_matches_[pair_idx];
|
||||
float ni = static_cast<float>(mi.num_inliers);
|
||||
float nf = static_cast<float>(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<Mat> &images, const vector<ImageFeatu
|
||||
if (_err)
|
||||
{
|
||||
calcError(err_);
|
||||
//LOGLN("Error: " << sqrt(err_.dot(err_)));
|
||||
LOGLN("Error: " << sqrt(err_.dot(err_)));
|
||||
count++;
|
||||
CvMat matErr = err_;
|
||||
cvCopy( &matErr, _err );
|
||||
|
@ -125,7 +125,8 @@ class BundleAdjuster : public Estimator
|
||||
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,
|
||||
@ -143,6 +144,7 @@ private:
|
||||
std::vector<std::pair<int,int> > edges_;
|
||||
|
||||
int cost_space_;
|
||||
float dist_thresh_;
|
||||
cv::Mat err_, err1_, err2_;
|
||||
cv::Mat J_;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user