Skip to content

Commit 9689331

Browse files
Merge pull request #1928 from alicevision/dev/featureMatchingParallelization
Enhancement of feature matching processing distribution amongs available chunks
2 parents 551b6cd + 1a04df9 commit 9689331

File tree

10 files changed

+310
-158
lines changed

10 files changed

+310
-158
lines changed

meshroom/aliceVision/FeatureMatching.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "2.0"
1+
__version__ = "2.1"
22

33
from meshroom.core import desc
44
from meshroom.core.utils import DESCRIBER_TYPES, VERBOSE_LEVEL
@@ -8,7 +8,7 @@ class FeatureMatching(desc.AVCommandLineNode):
88
commandLine = "aliceVision_featureMatching {allParams}"
99
size = avpar.DynamicViewsSize("input")
1010
parallelization = desc.Parallelization(blockSize=20)
11-
commandLineRange = "--rangeStart {rangeStart} --rangeSize {rangeBlockSize}"
11+
commandLineRange = "--rangeIteration {rangeIteration} --rangeBlocksCount {rangeBlocksCount}"
1212

1313
category = "Sparse Reconstruction"
1414
documentation = """

src/aliceVision/matchingImageCollection/ImagePairListIO.cpp

Lines changed: 31 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -14,36 +14,40 @@
1414
namespace aliceVision {
1515
namespace matchingImageCollection {
1616

17-
bool loadPairs(std::istream& stream, PairSet& pairs, int rangeStart, int rangeSize, bool useSymmetry)
17+
18+
bool loadPairsFromFile(const std::string& sFileName, // filename of the list file,
19+
PairSet& pairs,
20+
bool useSymmetry)
1821
{
22+
std::ifstream in(sFileName);
23+
if (!in.is_open())
24+
{
25+
ALICEVISION_LOG_WARNING("loadPairsFromFile: Impossible to read the specified file: \"" << sFileName << "\".");
26+
return false;
27+
}
28+
1929
std::size_t nbLine = 0;
2030
std::string sValue;
2131

22-
for (; std::getline(stream, sValue); ++nbLine)
32+
for (; std::getline(in, sValue); ++nbLine)
2333
{
24-
if (rangeStart != -1 && rangeSize != 0)
25-
{
26-
if (nbLine < rangeStart)
27-
continue;
28-
if (nbLine >= rangeStart + rangeSize)
29-
break;
30-
}
31-
3234
std::vector<std::string> vec_str;
3335
boost::trim(sValue);
3436
boost::split(vec_str, sValue, boost::is_any_of("\t "), boost::token_compress_on);
3537

3638
const size_t str_size = vec_str.size();
3739
if (str_size < 2)
3840
{
39-
ALICEVISION_LOG_WARNING("loadPairs: Invalid input file.");
41+
ALICEVISION_LOG_WARNING("loadPairsFromFile: Invalid input file.");
4042
return false;
4143
}
44+
4245
std::stringstream oss;
4346
oss.clear();
4447
oss.str(vec_str[0]);
4548
size_t I, J;
4649
oss >> I;
50+
4751
for (size_t i = 1; i < str_size; ++i)
4852
{
4953
oss.clear();
@@ -61,26 +65,29 @@ bool loadPairs(std::istream& stream, PairSet& pairs, int rangeStart, int rangeSi
6165
pairToInsert = std::make_pair(I, J);
6266
}
6367

64-
if (pairs.find(pairToInsert) != pairs.end())
65-
{
66-
// There is no reason to have the same image pair twice in the list of image pairs
67-
// to match.
68-
ALICEVISION_LOG_WARNING("loadPairs: image pair (" << I << ", " << J << ") already added.");
69-
}
70-
ALICEVISION_LOG_TRACE("loadPairs: image pair (" << I << ", " << J << ") added.");
68+
ALICEVISION_LOG_TRACE("loadPairsFromFile: image pair (" << I << ", " << J << ") added.");
7169
pairs.insert(pairToInsert);
7270
}
7371
}
72+
7473
return true;
7574
}
7675

77-
void savePairs(std::ostream& stream, const PairSet& pairs)
76+
bool savePairsToFile(const std::string& sFileName, const PairSet& pairs)
7877
{
78+
std::ofstream outStream(sFileName);
79+
if (!outStream.is_open())
80+
{
81+
ALICEVISION_LOG_WARNING("savePairsToFile: Impossible to open the output specified file: \"" << sFileName << "\".");
82+
return false;
83+
}
84+
7985
if (pairs.empty())
8086
{
81-
return;
87+
return true;
8288
}
83-
stream << pairs.begin()->first << " " << pairs.begin()->second;
89+
90+
outStream << pairs.begin()->first << " " << pairs.begin()->second;
8491
IndexT previousIndex = pairs.begin()->first;
8592

8693
// Pairs is sorted so we will always receive elements with the same first pair ID in
@@ -89,48 +96,15 @@ void savePairs(std::ostream& stream, const PairSet& pairs)
8996
{
9097
if (it->first == previousIndex)
9198
{
92-
stream << " " << it->second;
99+
outStream << " " << it->second;
93100
}
94101
else
95102
{
96-
stream << "\n" << it->first << " " << it->second;
103+
outStream << "\n" << it->first << " " << it->second;
97104
previousIndex = it->first;
98105
}
99106
}
100-
stream << "\n";
101-
}
102-
103-
bool loadPairsFromFile(const std::string& sFileName, // filename of the list file,
104-
PairSet& pairs,
105-
int rangeStart,
106-
int rangeSize,
107-
bool useSymmetry)
108-
{
109-
std::ifstream in(sFileName);
110-
if (!in.is_open())
111-
{
112-
ALICEVISION_LOG_WARNING("loadPairsFromFile: Impossible to read the specified file: \"" << sFileName << "\".");
113-
return false;
114-
}
115-
116-
if (!loadPairs(in, pairs, rangeStart, rangeSize, useSymmetry))
117-
{
118-
ALICEVISION_LOG_WARNING("loadPairsFromFile: Failed to read file: \"" << sFileName << "\".");
119-
return false;
120-
}
121-
return true;
122-
}
123-
124-
bool savePairsToFile(const std::string& sFileName, const PairSet& pairs)
125-
{
126-
std::ofstream outStream(sFileName);
127-
if (!outStream.is_open())
128-
{
129-
ALICEVISION_LOG_WARNING("savePairsToFile: Impossible to open the output specified file: \"" << sFileName << "\".");
130-
return false;
131-
}
132-
133-
savePairs(outStream, pairs);
107+
outStream << "\n";
134108

135109
return !outStream.bad();
136110
}

src/aliceVision/matchingImageCollection/ImagePairListIO.hpp

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@
55
// v. 2.0. If a copy of the MPL was not distributed with this file,
66
// You can obtain one at https://mozilla.org/MPL/2.0/.
77

8+
/**
9+
* @file ImagePairListIO.hpp
10+
* @brief Input/Output functions for reading and writing image pair lists.
11+
*
12+
* This file provides utilities for loading and saving sets of image pairs
13+
* to and from streams and files. Image pairs are used in the matching process
14+
* to define which images should be compared for feature matching.
15+
*/
16+
817
#include <aliceVision/types.hpp>
918

1019
#include <iosfwd>
@@ -13,23 +22,29 @@
1322
namespace aliceVision {
1423
namespace matchingImageCollection {
1524

16-
/// Load a set of PairSet from a stream
17-
/// I J K L (pair that link I)
18-
bool loadPairs(std::istream& stream, PairSet& pairs, int rangeStart = -1, int rangeSize = 0, bool useSymmetry = true);
19-
20-
/// Save a set of PairSet to a stream (one pair per line)
21-
/// I J
22-
/// I K
23-
void savePairs(std::ostream& stream, const PairSet& pairs);
24-
25-
/// Same as loadPairs, but loads from a given file
25+
/**
26+
* @brief Load image pairs from a file.
27+
*
28+
* Reads image pair data from the specified file and populates the pairs set.
29+
*
30+
* @param[in] sFileName Path to the file containing the pair data
31+
* @param[out] pairs Set of image pairs to be populated
32+
* @param[in] useSymmetry If true, add (min(i,j), max(i,j)) instead of (i,j) (default: true)
33+
* @return true if the file was opened and pairs were successfully loaded, false otherwise
34+
*/
2635
bool loadPairsFromFile(const std::string& sFileName, // filename of the list file,
2736
PairSet& pairs,
28-
int rangeStart = -1,
29-
int rangeSize = 0,
3037
bool useSymmetry = true);
3138

32-
/// Same as savePairs, but saves to a given file
39+
/**
40+
* @brief Save image pairs to a file.
41+
*
42+
* Writes the image pair data to the specified file.
43+
*
44+
* @param[in] sFileName Path to the output file
45+
* @param[in] pairs Set of image pairs to save
46+
* @return true if the file was created and pairs were successfully saved, false otherwise
47+
*/
3348
bool savePairsToFile(const std::string& sFileName, const PairSet& pairs);
3449

3550
} // namespace matchingImageCollection

0 commit comments

Comments
 (0)