/* Load matches from files */ void BaseApp::LoadMatches() { if (m_matches_loaded) return; /* we already loaded the matches */ if (m_match_table != NULL) { LoadMatchTable(m_match_table); } else if (m_match_index_dir != NULL) { LoadMatchIndexes(m_match_index_dir); } else { printf("[LoadMatches] Loading matches\n"); int num_images = GetNumImages(); FILE *f = fopen("match-index.txt", "r"); if (f == NULL) { /* Try all pairs */ for (int i = 0; i < num_images; i++) { for (int j = i+1; j < num_images; j++) { ReadMatchFile(i, j); } } } else { printf("[LoadMatches] Reading matches from 'match-index.txt'\n"); fflush(stdout); /* Set all matches to false */ // ClearMatches(); RemoveAllMatches(); char buf[256]; unsigned int count = 0; while (fgets(buf, 256, f)) { int i1, i2; sscanf(buf, "%d %d\n", &i1, &i2); ReadMatchFile(i1, i2); count++; } printf("[LoadMatches] Read %d match files\n", count); fflush(stdout); fclose(f); } } // WriteMatchTableDrew(".init"); PruneDoubleMatches(); m_matches_loaded = true; }
/* Load matches from files. Looks to see if there is a file that specifies which images should be matchedd. There are different options: a match table file, a match file directory, and a default matches text file plus associated key point match files. */ void BaseApp::LoadMatches() { if (m_matches_loaded) // Are matches already loaded? return; if (m_match_table != NULL) // Is there a filename specified? { LoadMatchTable(m_match_table); } else if (m_match_index_dir != NULL) // Or maybe a directory? { LoadMatchIndexes(m_match_index_dir); } else // Otherwise, go to default file(s). { #ifdef _DEBUG_ printf("[LoadMatches] Loading matches\n"); #endif int num_images = GetNumImages(); FILE *f = fopen("match-index.txt", "r"); // Try this file. if (f == NULL) // If not, try individual files. { /* Try all pairs */ for (int i = 0; i < num_images; i++) for (int j = i+1; j < num_images; j++) ReadMatchFile(i, j); } else // If so, the read it. { #ifdef _DEBUG_ printf("[LoadMatches] Reading matches from 'match-index.txt'\n"); fflush(stdout); #endif /* Clear all matches/match table. */ RemoveAllMatches(); char buf[256]; unsigned int count = 0; while (fgets(buf, 256, f)) { int i1, i2; sscanf(buf, "%d %d\n", &i1, &i2); // Read image pair (to load). ReadMatchFile(i1, i2); // Load match info from file. count++; } #ifdef _DEBUG_ printf("[LoadMatches] Read %d match files\n", count); fflush(stdout); #endif _DEBUG_ fclose(f); } } PruneDoubleMatches(); m_matches_loaded = true; }