Skip to content

Commit

Permalink
Merge pull request #1488 from alicevision/dev/tolerantBracketCount
Browse files Browse the repository at this point in the history
tolerant bracket size estimation
  • Loading branch information
cbentejac authored Jul 17, 2023
2 parents 60c531e + 19c2ec7 commit d092124
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 9 deletions.
36 changes: 32 additions & 4 deletions src/aliceVision/hdr/brackets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ bool estimateBracketsFromSfmData(std::vector<std::vector<std::shared_ptr<sfmData
return false;
}

if ((countBrackets > 0) && ((countImages % countBrackets) != 0))
{
return false;
}

const sfmData::Views & views = sfmData.getViews();

Expand Down Expand Up @@ -79,6 +75,7 @@ bool estimateBracketsFromSfmData(std::vector<std::vector<std::shared_ptr<sfmData
group.clear();
}

lastExposure = exp;
group.push_back(view);
}
}
Expand All @@ -88,6 +85,37 @@ bool estimateBracketsFromSfmData(std::vector<std::vector<std::shared_ptr<sfmData
groups.push_back(group);
}


//Check maximal size
int maxSize = 0;
for (auto & group : groups)
{
if (group.size() > maxSize)
{
maxSize = group.size();
}
}

//Only keep groups with majority group size
auto groupIt = groups.begin();
while (groupIt != groups.end())
{
if (groupIt->size() != maxSize)
{
groupIt = groups.erase(groupIt);
}
else
{
groupIt++;
}
}

//Make sure we only have a few spurious measures
if (groups.size() * maxSize < countImages - 2)
{
return false;
}

std::vector< std::vector<sfmData::ExposureSetting>> v_exposuresSetting;
for(auto & group : groups)
{
Expand Down
6 changes: 1 addition & 5 deletions src/software/pipeline/main_LdrToHdrMerge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,6 @@ int aliceVision_main(int argc, char** argv)
ALICEVISION_LOG_ERROR("The input SfMData contains no image.");
return EXIT_FAILURE;
}
if(nbBrackets > 0 && (countImages % nbBrackets) != 0)
{
ALICEVISION_LOG_ERROR("The input SfMData file (" << countImages << " images) is not compatible with the number of brackets (" << nbBrackets << " brackets).");
return EXIT_FAILURE;
}
if(nbBrackets == 1 && !byPass)
{
ALICEVISION_LOG_WARNING("Enable bypass as there is only one input bracket.");
Expand All @@ -191,6 +186,7 @@ int aliceVision_main(int argc, char** argv)
std::vector<std::vector<std::shared_ptr<sfmData::View>>> groupedViews;
if (!hdr::estimateBracketsFromSfmData(groupedViews, sfmData, nbBrackets))
{
ALICEVISION_LOG_ERROR("Failure to estimate brackets.");
return EXIT_FAILURE;
}

Expand Down
1 change: 1 addition & 0 deletions src/software/pipeline/main_LdrToHdrSampling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ int aliceVision_main(int argc, char** argv)
std::vector<std::vector<std::shared_ptr<sfmData::View>>> groupedViews;
if (!hdr::estimateBracketsFromSfmData(groupedViews, sfmData, nbBrackets))
{
ALICEVISION_LOG_ERROR("Failure to estimate brackets.");
return EXIT_FAILURE;
}

Expand Down

0 comments on commit d092124

Please sign in to comment.