Skip to content

Commit

Permalink
Merge pull request #739 from alicevision/fix/imageMatching_minNbImages
Browse files Browse the repository at this point in the history
image matching: fix min nb images
  • Loading branch information
fabiencastan authored Feb 7, 2020
2 parents 2e3293d + c87ebe1 commit e625d22
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
15 changes: 9 additions & 6 deletions src/software/pipeline/main_featureMatching.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ int main(int argc, char **argv)
std::string geometricFilterTypeName = matchingImageCollection::EGeometricFilterType_enumToString(matchingImageCollection::EGeometricFilterType::FUNDAMENTAL_MATRIX);
std::string describerTypesName = feature::EImageDescriberType_enumToString(feature::EImageDescriberType::SIFT);
float distRatio = 0.8f;
std::string predefinedPairList;
std::vector<std::string> predefinedPairList;
int rangeStart = -1;
int rangeSize = 0;
std::string nearestMatchingMethod = "ANN_L2";
Expand Down Expand Up @@ -140,8 +140,8 @@ int main(int argc, char **argv)
matchingImageCollection::EGeometricFilterType_informations().c_str())
("describerTypes,d", po::value<std::string>(&describerTypesName)->default_value(describerTypesName),
feature::EImageDescriberType_informations().c_str())
("imagePairsList,l", po::value<std::string>(&predefinedPairList)->default_value(predefinedPairList),
"Path to a file which contains the list of image pairs to match.")
("imagePairsList,l", po::value<std::vector<std::string>>(&predefinedPairList)->multitoken(),
"Path(s) to one or more files which contain the list of image pairs to match.")
("photometricMatchingMethod,p", po::value<std::string>(&nearestMatchingMethod)->default_value(nearestMatchingMethod),
"For Scalar based regions descriptor:\n"
"* BRUTE_FORCE_L2: L2 BruteForce matching\n"
Expand Down Expand Up @@ -271,9 +271,12 @@ int main(int argc, char **argv)
}
else
{
ALICEVISION_LOG_INFO("Load pair list from file: " << predefinedPairList);
if(!loadPairs(predefinedPairList, pairs, rangeStart, rangeSize))
return EXIT_FAILURE;
for(const std::string& imagePairsFile: predefinedPairList)
{
ALICEVISION_LOG_INFO("Load pair list from file: " << imagePairsFile);
if(!loadPairs(imagePairsFile, pairs, rangeStart, rangeSize))
return EXIT_FAILURE;
}
}

if(pairs.empty())
Expand Down
17 changes: 16 additions & 1 deletion src/software/pipeline/main_imageMatching.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,12 @@ int main(int argc, char** argv)
po::options_description optionalParams("Optional parameters");
optionalParams.add_options()
("method", po::value<EImageMatchingMethod>(&method)->default_value(method),
"Method used to select the image pairs to match.")
"Method used to select the image pairs to match:\n"
" * VocabularyTree: select images that appear to share content\n"
" * Sequential: use images neighbors based on filename\n"
" * SequentialAndVocabularyTree: combine both previous approaches\n"
" * Exhaustive: all images combinations\n"
" * Frustum: images with camera frustum intersection (only for cameras with known poses)\n")
("minNbImages", po::value<std::size_t>(&minNbImages)->default_value(minNbImages),
"Minimal number of images to use the vocabulary tree. If we have less images than this threshold, we will compute all matching combinations.")
("maxDescriptors", po::value<std::size_t>(&nbMaxDescriptors)->default_value(nbMaxDescriptors),
Expand Down Expand Up @@ -714,6 +719,16 @@ int main(int argc, char** argv)
if(useMultiSfM)
aliceVision::voctree::getListOfDescriptorFiles(sfmDataB, featuresFolders, descriptorsFilesB);

// if not enough images to use the VOCABULARYTREE use the EXHAUSTIVE method
if(method == EImageMatchingMethod::VOCABULARYTREE || method == EImageMatchingMethod::SEQUENTIAL_AND_VOCABULARYTREE)
{
if((descriptorsFilesA.size() + descriptorsFilesB.size()) < minNbImages)
{
ALICEVISION_LOG_DEBUG("Use EXHAUSTIVE method instead of VOCABULARYTREE (less images than minNbImages).");
method = EImageMatchingMethod::EXHAUSTIVE;
}
}

switch(method)
{
case EImageMatchingMethod::EXHAUSTIVE:
Expand Down

0 comments on commit e625d22

Please sign in to comment.