Skip to content

Commit

Permalink
[software] Do not fail if range start is larger than the number of views
Browse files Browse the repository at this point in the history
For cases where a node declares a size that is bigger than it actually is,
the start of ranges might exceed the number of views in the SfMData.

Instead of causing an EXIT_FAILURE, we detect that the size of the range
is incorrect to proceed with computations, and return EXIT_SUCCESS.

This allows to use nodes such as the `KeyframeSelection`, for which the
number of outputs can rarely be known before the end of the computations:
if the number of chunks for `PrepareDenseScene` and `FeatureExtraction` is
too large for the actual size of `KeyframeSelection`, then we keep on
going through the pipeline instead of failing.
  • Loading branch information
cbentejac committed Jun 8, 2023
1 parent 6e3d3ca commit 222b020
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
8 changes: 6 additions & 2 deletions src/software/pipeline/main_featureExtraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ int aliceVision_main(int argc, char **argv)
// set extraction range
if(rangeStart != -1)
{
if(rangeStart < 0 || rangeSize < 0 ||
rangeStart > sfmData.getViews().size())
if(rangeStart < 0 || rangeSize < 0)
{
ALICEVISION_LOG_ERROR("Range is incorrect");
return EXIT_FAILURE;
Expand All @@ -152,6 +151,11 @@ int aliceVision_main(int argc, char **argv)
if(rangeStart + rangeSize > sfmData.views.size())
rangeSize = sfmData.views.size() - rangeStart;

if(rangeSize <= 0)
{
ALICEVISION_LOG_WARNING("Nothing to compute.");
return EXIT_SUCCESS;
}

extractor.setRange(rangeStart, rangeSize);
}
Expand Down
14 changes: 10 additions & 4 deletions src/software/pipeline/main_prepareDenseScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ bool prepareDenseScene(const SfMData& sfmData,
projectionMatrix << P(0, 0), P(0, 1), P(0, 2), P(0, 3),
P(1, 0), P(1, 1), P(1, 2), P(1, 3),
P(2, 0), P(2, 1), P(2, 2), P(2, 3),
0, 0, 0, 1;
0, 0, 0, 1;

// convert matrices to rowMajor
std::vector<double> vP(projectionMatrix.size());
Expand Down Expand Up @@ -346,8 +346,7 @@ int aliceVision_main(int argc, char *argv[])
// set range
if(rangeStart != -1)
{
if(rangeStart < 0 || rangeSize < 0 ||
rangeStart > sfmData.getViews().size())
if(rangeStart < 0 || rangeSize < 0)
{
ALICEVISION_LOG_ERROR("Range is incorrect");
return EXIT_FAILURE;
Expand All @@ -357,14 +356,21 @@ int aliceVision_main(int argc, char *argv[])
rangeSize = sfmData.views.size() - rangeStart;

rangeEnd = rangeStart + rangeSize;

if(rangeSize <= 0)
{
ALICEVISION_LOG_WARNING("Nothing to compute.");
return EXIT_SUCCESS;
}
}
else
{
rangeStart = 0;
}

// export
if(prepareDenseScene(sfmData, imagesFolders, masksFolders, rangeStart, rangeEnd, outFolder, outputFileType, saveMetadata, saveMatricesTxtFiles, evCorrection))
if(prepareDenseScene(sfmData, imagesFolders, masksFolders, rangeStart, rangeEnd,
outFolder, outputFileType, saveMetadata, saveMatricesTxtFiles, evCorrection))
return EXIT_SUCCESS;

return EXIT_FAILURE;
Expand Down

0 comments on commit 222b020

Please sign in to comment.