Fixed median focal length estimation in the stitching module
This commit is contained in:
parent
b74e9c101a
commit
28e006ad4f
@ -120,9 +120,16 @@ void estimateFocal(const vector<ImageFeatures> &features, const vector<MatchesIn
|
||||
|
||||
if (static_cast<int>(all_focals.size()) >= num_images - 1)
|
||||
{
|
||||
nth_element(all_focals.begin(), all_focals.begin() + all_focals.size()/2, all_focals.end());
|
||||
double median;
|
||||
|
||||
sort(all_focals.begin(), all_focals.end());
|
||||
if (all_focals.size() % 2 == 1)
|
||||
median = all_focals[all_focals.size() / 2];
|
||||
else
|
||||
median = (all_focals[all_focals.size() / 2 - 1] + all_focals[all_focals.size() / 2]) * 0.5;
|
||||
|
||||
for (int i = 0; i < num_images; ++i)
|
||||
focals[i] = all_focals[all_focals.size()/2];
|
||||
focals[i] = median;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -442,8 +442,13 @@ void Stitcher::estimateCameraParams()
|
||||
LOGLN("Camera #" << indices_[i] + 1 << ":\n" << cameras_[i].K());
|
||||
focals.push_back(cameras_[i].focal);
|
||||
}
|
||||
nth_element(focals.begin(), focals.begin() + focals.size()/2, focals.end());
|
||||
warped_image_scale_ = static_cast<float>(focals[focals.size() / 2]);
|
||||
|
||||
sort(focals.begin(), focals.end());
|
||||
float warped_image_scale;
|
||||
if (focals.size() % 2 == 1)
|
||||
warped_image_scale = static_cast<float>(focals[focals.size() / 2]);
|
||||
else
|
||||
warped_image_scale = static_cast<float>(focals[focals.size() / 2 - 1] + focals[focals.size() / 2]) * 0.5f;
|
||||
|
||||
if (do_wave_correct_)
|
||||
{
|
||||
|
@ -486,14 +486,20 @@ int main(int argc, char* argv[])
|
||||
(*adjuster)(features, pairwise_matches, cameras);
|
||||
|
||||
// Find median focal length
|
||||
|
||||
vector<double> focals;
|
||||
for (size_t i = 0; i < cameras.size(); ++i)
|
||||
{
|
||||
LOGLN("Camera #" << indices[i]+1 << ":\n" << cameras[i].K());
|
||||
focals.push_back(cameras[i].focal);
|
||||
}
|
||||
nth_element(focals.begin(), focals.begin() + focals.size()/2, focals.end());
|
||||
float warped_image_scale = static_cast<float>(focals[focals.size() / 2]);
|
||||
|
||||
sort(focals.begin(), focals.end());
|
||||
float warped_image_scale;
|
||||
if (focals.size() % 2 == 1)
|
||||
warped_image_scale = static_cast<float>(focals[focals.size() / 2]);
|
||||
else
|
||||
warped_image_scale = static_cast<float>(focals[focals.size() / 2 - 1] + focals[focals.size() / 2]) * 0.5f;
|
||||
|
||||
if (do_wave_correct)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user