| 27 | namespace matching { |
| 28 | |
| 29 | bool LoadMatchFile(PairwiseMatches& matches, const std::string& filepath) |
| 30 | { |
| 31 | const std::string ext = fs::path(filepath).extension().string(); |
| 32 | |
| 33 | if (!utils::exists(filepath)) |
| 34 | return false; |
| 35 | |
| 36 | if (ext == ".txt") |
| 37 | { |
| 38 | std::ifstream stream(filepath); |
| 39 | if (!stream.is_open()) |
| 40 | return false; |
| 41 | |
| 42 | // Read from the text file |
| 43 | // I J |
| 44 | // nbDescType |
| 45 | // descType matchesCount |
| 46 | // idx idx |
| 47 | // ... |
| 48 | // descType matchesCount |
| 49 | // idx idx |
| 50 | // ... |
| 51 | std::size_t I = 0; |
| 52 | std::size_t J = 0; |
| 53 | std::size_t nbDescType = 0; |
| 54 | while (stream >> I >> J >> nbDescType) |
| 55 | { |
| 56 | for (std::size_t i = 0; i < nbDescType; ++i) |
| 57 | { |
| 58 | std::string descTypeStr; |
| 59 | std::size_t nbMatches = 0; |
| 60 | // Read descType and number of matches |
| 61 | stream >> descTypeStr >> nbMatches; |
| 62 | |
| 63 | feature::EImageDescriberType descType = feature::EImageDescriberType_stringToEnum(descTypeStr); |
| 64 | std::vector<IndMatch> matchesPerDesc(nbMatches); |
| 65 | // Read all matches |
| 66 | for (std::size_t i = 0; i < nbMatches; ++i) |
| 67 | { |
| 68 | stream >> matchesPerDesc[i]; |
| 69 | } |
| 70 | matches[std::make_pair(I, J)][descType] = std::move(matchesPerDesc); |
| 71 | } |
| 72 | } |
| 73 | stream.close(); |
| 74 | return true; |
| 75 | } |
| 76 | else |
| 77 | { |
| 78 | ALICEVISION_LOG_WARNING("Unknown matching file format: " << ext); |
| 79 | } |
| 80 | return false; |
| 81 | } |
| 82 | |
| 83 | void filterMatchesByViews(PairwiseMatches& matches, const std::set<IndexT>& viewsKeys) |
| 84 | { |
no test coverage detected