| 276 | } |
| 277 | |
| 278 | std::map<std::string, IndexT> retrieveMatchingFilepath(const sfmData::SfMData& sfmData, const std::string& filePatternMatching) |
| 279 | { |
| 280 | std::set<std::string> duplicates; |
| 281 | std::map<std::string, IndexT> uniqueFileparts; |
| 282 | for (auto& viewIt : sfmData.getViews()) |
| 283 | { |
| 284 | const std::string& imagePath = viewIt.second->getImage().getImagePath(); |
| 285 | std::string cumulatedValues; |
| 286 | if (filePatternMatching.empty()) |
| 287 | { |
| 288 | cumulatedValues = imagePath; |
| 289 | } |
| 290 | else |
| 291 | { |
| 292 | std::regex re(filePatternMatching); |
| 293 | std::smatch matches; |
| 294 | if (std::regex_match(imagePath, matches, re)) |
| 295 | { |
| 296 | for (int i = 1; i < matches.size(); ++i) |
| 297 | { |
| 298 | const std::ssub_match& submatch = matches[i]; |
| 299 | cumulatedValues += submatch.str(); |
| 300 | } |
| 301 | } |
| 302 | } |
| 303 | ALICEVISION_LOG_TRACE("retrieveMatchingFilepath: " << imagePath << " -> " << cumulatedValues); |
| 304 | auto it = uniqueFileparts.find(cumulatedValues); |
| 305 | if (it != uniqueFileparts.end()) |
| 306 | { |
| 307 | duplicates.insert(cumulatedValues); |
| 308 | } |
| 309 | else |
| 310 | { |
| 311 | uniqueFileparts[cumulatedValues] = viewIt.first; |
| 312 | } |
| 313 | } |
| 314 | for (const std::string& d : duplicates) |
| 315 | { |
| 316 | uniqueFileparts.erase(d); |
| 317 | } |
| 318 | return uniqueFileparts; |
| 319 | } |
| 320 | |
| 321 | void matchViewsByFilePattern(const sfmData::SfMData& sfmDataA, |
| 322 | const sfmData::SfMData& sfmDataB, |