fixed some bugs in opencv_stitching
This commit is contained in:
parent
899d7726d3
commit
c65a39be82
@ -110,7 +110,7 @@ void estimateFocal(const vector<ImageFeatures> &features, const vector<MatchesIn
|
||||
}
|
||||
else
|
||||
{
|
||||
nth_element(all_focals.begin(), all_focals.end(), all_focals.begin() + all_focals.size()/2);
|
||||
nth_element(all_focals.begin(), all_focals.begin() + all_focals.size()/2, all_focals.end());
|
||||
for (int i = 0; i < num_images; ++i)
|
||||
focals[i] = all_focals[all_focals.size()/2];
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ void OverlapExposureCompensator::feed(const vector<Point> &corners, const vector
|
||||
const vector<Mat> &masks)
|
||||
{
|
||||
const int num_images = static_cast<int>(images.size());
|
||||
Mat_<double> N(num_images, num_images); N.setTo(0);
|
||||
Mat_<int> N(num_images, num_images); N.setTo(0);
|
||||
Mat_<double> I(num_images, num_images); I.setTo(0);
|
||||
|
||||
Rect dst_roi = resultRoi(corners, images);
|
||||
@ -99,8 +99,8 @@ void OverlapExposureCompensator::feed(const vector<Point> &corners, const vector
|
||||
}
|
||||
}
|
||||
}
|
||||
I(i, j) = Isum1 / N(i, j);
|
||||
I(j, i) = Isum2 / N(i, j);
|
||||
I(i, j) = Isum1 / max(N(i, j), 1);
|
||||
I(j, i) = Isum2 / max(N(i, j), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -341,8 +341,13 @@ int main(int argc, char* argv[])
|
||||
vector<Mat> img_subset;
|
||||
vector<string> img_names_subset;
|
||||
for (size_t i = 0; i < indices.size(); ++i)
|
||||
{
|
||||
img_names_subset.push_back(img_names[indices[i]]);
|
||||
img_subset.push_back(images[indices[i]]);
|
||||
}
|
||||
|
||||
img_names = img_names_subset;
|
||||
images = img_subset;
|
||||
|
||||
// Check if we still have enough images
|
||||
num_images = static_cast<int>(img_names.size());
|
||||
@ -393,7 +398,7 @@ int main(int argc, char* argv[])
|
||||
LOGLN("Camera #" << i << " focal length: " << cameras[i].focal);
|
||||
focals.push_back(cameras[i].focal);
|
||||
}
|
||||
nth_element(focals.begin(), focals.end(), focals.begin() + focals.size() / 2);
|
||||
nth_element(focals.begin(), focals.begin() + focals.size()/2, focals.end());
|
||||
float warped_image_scale = static_cast<float>(focals[focals.size() / 2]);
|
||||
|
||||
LOGLN("Warping images (auxiliary)... ");
|
||||
|
@ -265,7 +265,7 @@ void FeaturesMatcher::operator ()(const vector<ImageFeatures> &features, vector<
|
||||
|
||||
// Leave k-nearest images
|
||||
int k = min(4, num_images);
|
||||
nth_element(dists.begin(), dists.end(), dists.begin() + k);
|
||||
nth_element(dists.begin(), dists.begin() + k, dists.end());
|
||||
for (int j = 0; j < k; ++j)
|
||||
is_near(i, dists[j].idx) = 1;
|
||||
}
|
||||
@ -273,7 +273,7 @@ void FeaturesMatcher::operator ()(const vector<ImageFeatures> &features, vector<
|
||||
vector<pair<int,int> > near_pairs;
|
||||
for (int i = 0; i < num_images - 1; ++i)
|
||||
for (int j = i + 1; j < num_images; ++j)
|
||||
if (is_near(i, j))
|
||||
if (is_near(i, j) || is_near(j, i))
|
||||
near_pairs.push_back(make_pair(i, j));
|
||||
|
||||
pairwise_matches.resize(num_images * num_images);
|
||||
|
Loading…
Reference in New Issue
Block a user