From f2d7b035870b25bb96efc54437014633542c9188 Mon Sep 17 00:00:00 2001 From: Simone Gasparini Date: Fri, 12 Jun 2020 19:29:06 +0200 Subject: [PATCH 1/2] [doc] fix typo --- CONTRIBUTING.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a5337f717d..15db3c6a1d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,8 +12,7 @@ Contributing Workflow The contributing workflow relies on [Github Pull Requests](https://help.github.com/articles/using-pull-requests/). 1. If it is an important change, we recommend you to discuss it on the mailing-list -before starting implementation. This ensure that the development is aligned with other -developpements already started and will be efficiently integrated. +before starting implementation. This ensure that the development is aligned with other developments already started and will be efficiently integrated. 2. Create the corresponding issues. From 402a41a022202106e9fce131ed7aed9941a0fab4 Mon Sep 17 00:00:00 2001 From: Simone Gasparini Date: Fri, 12 Jun 2020 19:30:15 +0200 Subject: [PATCH 2/2] [matching] fix unmatching function declarations and definitions --- src/aliceVision/matching/io.cpp | 63 ++++++++++--------------- src/aliceVision/matching/io.hpp | 81 +++++++++++++++++---------------- 2 files changed, 66 insertions(+), 78 deletions(-) diff --git a/src/aliceVision/matching/io.cpp b/src/aliceVision/matching/io.cpp index b16a274576..c22a74d86a 100644 --- a/src/aliceVision/matching/io.cpp +++ b/src/aliceVision/matching/io.cpp @@ -78,10 +78,7 @@ bool LoadMatchFile(PairwiseMatches& matches, const std::string& filepath) return false; } - -void filterMatchesByViews( - PairwiseMatches & matches, - const std::set & viewsKeys) +void filterMatchesByViews(PairwiseMatches& matches, const std::set& viewsKeys) { matching::PairwiseMatches filteredMatches; for (matching::PairwiseMatches::const_iterator iter = matches.begin(); @@ -97,14 +94,11 @@ void filterMatchesByViews( matches.swap(filteredMatches); } -void filterTopMatches( - PairwiseMatches & allMatches, - const int limitNum, - const int minNum) +void filterTopMatches(PairwiseMatches& allMatches, int maxNum, int minNum) { - if (limitNum <= 0 && minNum <=0) + if (maxNum <= 0 && minNum <=0) return; - if (limitNum > 0 && minNum > limitNum) + if (maxNum > 0 && minNum > maxNum) throw std::runtime_error("The minimum number of matches is higher than the maximum."); for(auto& matchesPerDesc: allMatches) @@ -114,15 +108,13 @@ void filterTopMatches( IndMatches& m = matches.second; if (minNum > 0 && m.size() < minNum) m.clear(); - else if (limitNum > 0 && m.size() > limitNum) - m.erase(m.begin()+limitNum, m.end()); + else if (maxNum > 0 && m.size() > maxNum) + m.erase(m.begin()+ maxNum, m.end()); } } } -void filterMatchesByDesc( - PairwiseMatches & allMatches, - const std::vector& descTypesFilter) +void filterMatchesByDesc(PairwiseMatches& allMatches, const std::vector& descTypesFilter) { matching::PairwiseMatches filteredMatches; for(const auto& matchesPerDesc: allMatches) @@ -138,12 +130,10 @@ void filterMatchesByDesc( allMatches.swap(filteredMatches); } - -std::size_t LoadMatchFilePerImage( - PairwiseMatches& matches, - const std::set& viewsKeys, - const std::string& folder, - const std::string& basename) +std::size_t LoadMatchFilePerImage(PairwiseMatches& matches, + const std::set& viewsKeys, + const std::string& folder, + const std::string& extension) { int nbLoadedMatchFiles = 0; // Load one match file per image @@ -153,7 +143,7 @@ std::size_t LoadMatchFilePerImage( std::set::const_iterator it = viewsKeys.begin(); std::advance(it, i); const IndexT idView = *it; - const std::string matchFilename = std::to_string(idView) + "." + basename; + const std::string matchFilename = std::to_string(idView) + "." + extension; PairwiseMatches fileMatches; if(!LoadMatchFile(fileMatches, (fs::path(folder) / matchFilename).string() )) { @@ -232,13 +222,12 @@ std::size_t loadMatchesFromFolder(PairwiseMatches& matches, const std::string& f return nbLoadedMatchFiles; } -bool Load( - PairwiseMatches& matches, - const std::set& viewsKeysFilter, - const std::vector& folders, - const std::vector& descTypesFilter, - const int maxNbMatches, - const int minNbMatches) +bool Load(PairwiseMatches& matches, + const std::set& viewsKeysFilter, + const std::vector& folders, + const std::vector& descTypesFilter, + int maxNbMatches, + int minNbMatches) { std::size_t nbLoadedMatchFiles = 0; const std::string pattern = "matches.txt"; @@ -332,8 +321,7 @@ class MatchExporter , m_ext(fs::extension(filename)) {} - ~MatchExporter() - {} + ~MatchExporter() = default; void saveGlobalFile() { @@ -380,14 +368,11 @@ class MatchExporter std::string m_filename; }; - -bool Save( - const PairwiseMatches & matches, - const std::string & folder, - const std::string & extension, - bool matchFilePerImage, - const std::string& prefix - ) +bool Save(const PairwiseMatches& matches, + const std::string& folder, + const std::string& extension, + bool matchFilePerImage, + const std::string& prefix) { const std::string filename = prefix + "matches." + extension; MatchExporter exporter(matches, folder, filename); diff --git a/src/aliceVision/matching/io.hpp b/src/aliceVision/matching/io.hpp index 9e92555f39..7fbfd848e8 100644 --- a/src/aliceVision/matching/io.hpp +++ b/src/aliceVision/matching/io.hpp @@ -14,76 +14,79 @@ namespace aliceVision { namespace matching { - + /** * @brief Load a match file. * - * @param[out] matches: container for the output matches - * @param[in] folder: folder containing the match files + * @param[out] matches container for the output matches + * @param[in] filepath the match file to load */ -bool LoadMatchFile( - PairwiseMatches& matches, - const std::string& folder, - const std::string& filename); +bool LoadMatchFile(PairwiseMatches& matches, const std::string& filepath); /** * @brief Load the match file for each image. - * - * @param[out] matches: container for the output matches - * @param[in] folder: folder containing the match files + * @param[out] matches container for the output matches. + * @param[in] viewsKeys the list of views whose match files need to be loaded. + * @param[in] folder the folder where to look for all the files. + * @param[in] extension the extension of the match file. + * @return the number of match file actually loaded (if a file cannot be loaded it is discarded) */ -bool LoadMatchFilePerImage( - PairwiseMatches& matches, - const std::set& viewsKeys, - const std::string& folder); +std::size_t LoadMatchFilePerImage(PairwiseMatches& matches, + const std::set& viewsKeys, + const std::string& folder, + const std::string& extension); /** - * @brief Load match files. + * @brief Load all the matches from the folder. Optionally filter the view, the type of descriptors + * and the number of matches. * - * @param[out] matches: container for the output matches - * @param[in] sfm_data - * @param[in] folder: folder containing the match files - * @param[in] descTypes - * @param[in] maxNbMatches: to load the N first matches for each desc. type. Load all the matches by default (: 0) + * @param[out] matches container for the output matches. + * @param[in] viewsKeysFilter Restrict the matches to these views. + * @param[in] folders The list of folder from where to lead the match files. + * @param[in] descTypesFilter Restrict the matches to these types of descriptors. + * @param[in] maxNbMatches keep at most \p maxNbMatches matches (0 takes all matches). + * @param[in] minNbMatches discard the match files with less than \p minNbMatches (0 takes all files). + * @return \p false if no file could be loaded. + * @see filterMatchesByViews + * @see filterTopMatches */ bool Load(PairwiseMatches& matches, - const std::set& viewsKeysFilter, - const std::vector& folders, - const std::vector& descTypesFilter, - const int maxNbMatches = 0, - const int minNbMatches =0); + const std::set& viewsKeysFilter, + const std::vector& folders, + const std::vector& descTypesFilter, + int maxNbMatches = 0, + int minNbMatches = 0); /** * @brief Filter to keep only specific viewIds. + * @param[in,out] matches the matches to filter. + * @param[in] viewsKeys the list of views to keep. */ -void filterMatchesByViews( - PairwiseMatches& matches, - const std::set& viewsKeys); +void filterMatchesByViews(PairwiseMatches& matches, const std::set& viewsKeys); /** - * @brief Filter to keep only the \c limitNum first matches per descriptor type. + * @brief Filter to keep only the \c limitNum first matches per descriptor type. + * @param[in,out] allMatches he matches to filter. + * @param[in] maxNum The maximum number of matches to retrieve. + * @param[in] minNum The minimum number of matches that the file must contain (otherwise it is discarded). */ -void filterTopMatches( - PairwiseMatches& allMatches, - const int limitNum); +void filterTopMatches(PairwiseMatches& allMatches, int maxNum, int minNum); /** * @brief Save match files. * * @param[in] matches: container for the output matches - * @param[in] sfm_data * @param[in] folder: folder containing the match files * @param[in] extension: txt or bin file format * @param[in] matchFilePerImage: do we store a global match file * or one match file per image * @param[in] prefix: optional prefix for the output file(s) */ -bool Save( - const PairwiseMatches& matches, - const std::string& folder, - const std::string& extension, - bool matchFilePerImage, - const std::string& prefix=""); +bool Save(const PairwiseMatches& matches, + const std::string& folder, + const std::string& extension, + bool matchFilePerImage, + const std::string& prefix = ""); } // namespace matching } // namespace aliceVision