10
10
#include < aliceVision/system/Timer.hpp>
11
11
#include < aliceVision/system/Logger.hpp>
12
12
#include < aliceVision/system/main.hpp>
13
+ #include < aliceVision/system/Parallelization.hpp>
13
14
#include < aliceVision/cmdline/cmdline.hpp>
14
15
15
16
#include < aliceVision/sfmData/SfMData.hpp>
@@ -140,8 +141,8 @@ int aliceVision_main(int argc, char** argv)
140
141
std::string sfmDataFilename;
141
142
std::string tracksFilename;
142
143
std::string outputDirectory;
143
- int rangeStart = - 1 ;
144
- int rangeSize = 1 ;
144
+ int rangeIteration = 0 ;
145
+ int rangeBlocksCount = 1 ;
145
146
size_t minInliers = 35 ;
146
147
bool enforcePureRotation = false ;
147
148
size_t countIterations = 1024 ;
@@ -166,8 +167,8 @@ int aliceVision_main(int argc, char** argv)
166
167
(" minInliers" , po::value<size_t >(&minInliers)->default_value (minInliers), " Minimal number of inliers for a valid ransac." )
167
168
(" imagePairsList,l" , po::value<std::vector<std::string>>(&predefinedPairList)->multitoken (),
168
169
" Path(s) to one or more files which contain the list of image pairs to match." )
169
- (" rangeStart " , po::value<int >(&rangeStart )->default_value (rangeStart ), " Range image index start ." )
170
- (" rangeSize " , po::value<int >(&rangeSize )->default_value (rangeSize ), " Range size ." );
170
+ (" rangeIteration " , po::value<int >(&rangeIteration )->default_value (rangeIteration ), " Chunk id ." )
171
+ (" rangeBlocksCount " , po::value<int >(&rangeBlocksCount )->default_value (rangeBlocksCount ), " Chunk count ." );
171
172
// clang-format on
172
173
173
174
CmdLine cmdline (" AliceVision relativePoseEstimating" );
@@ -193,33 +194,6 @@ int aliceVision_main(int argc, char** argv)
193
194
return EXIT_FAILURE;
194
195
}
195
196
196
- // Define range to compute
197
- if (rangeStart != -1 )
198
- {
199
- if (rangeStart < 0 || rangeSize < 0 )
200
- {
201
- ALICEVISION_LOG_ERROR (" Range is incorrect" );
202
- return EXIT_FAILURE;
203
- }
204
-
205
- if (rangeStart > sfmData.getViews ().size ())
206
- {
207
- ALICEVISION_LOG_INFO (" Empty range to compute" );
208
- return EXIT_SUCCESS;
209
- }
210
-
211
- if (rangeStart + rangeSize > sfmData.getViews ().size ())
212
- {
213
- rangeSize = sfmData.getViews ().size () - rangeStart;
214
- }
215
- }
216
- else
217
- {
218
- rangeStart = 0 ;
219
- rangeSize = sfmData.getViews ().size ();
220
- }
221
- ALICEVISION_LOG_DEBUG (" Range to compute: rangeStart=" << rangeStart << " , rangeSize=" << rangeSize);
222
-
223
197
224
198
// Load tracks
225
199
ALICEVISION_LOG_INFO (" Load tracks from " << tracksFilename << " ." );
@@ -233,20 +207,14 @@ int aliceVision_main(int argc, char** argv)
233
207
ALICEVISION_LOG_INFO (" Compute co-visibility" );
234
208
std::map<Pair, unsigned int > covisibility;
235
209
236
- int chunkStart = 0 ;
237
- int chunkEnd = 0 ;
210
+
238
211
239
212
if (predefinedPairList.empty ())
240
213
{
241
214
// Compute covisibility for tracks
242
215
// This will get the list of pair of views which observe common features
243
216
ALICEVISION_LOG_INFO (" Automatically select pairs." );
244
217
track::computeCovisibility (covisibility, tracksHandler.getAllTracks ());
245
-
246
- // Divide the work among chunks
247
- double ratioChunk = double (covisibility.size ()) / double (sfmData.getViews ().size ());
248
- chunkStart = int (double (rangeStart) * ratioChunk);
249
- chunkEnd = int (double (rangeStart + rangeSize) * ratioChunk);
250
218
}
251
219
else
252
220
{
@@ -256,7 +224,7 @@ int aliceVision_main(int argc, char** argv)
256
224
PairSet pairs;
257
225
258
226
ALICEVISION_LOG_INFO (" Load pair list from file: " << imagePairsFile);
259
- if (!matchingImageCollection::loadPairsFromFile (imagePairsFile, pairs, rangeStart, rangeSize ))
227
+ if (!matchingImageCollection::loadPairsFromFile (imagePairsFile, pairs, 0 , - 1 ))
260
228
{
261
229
return EXIT_FAILURE;
262
230
}
@@ -273,10 +241,12 @@ int aliceVision_main(int argc, char** argv)
273
241
covisibility[other] = 1 ;
274
242
}
275
243
}
244
+ }
276
245
277
- // Just process everything as it was already filtered during file loading
278
- chunkStart = 0 ;
279
- chunkEnd = covisibility.size ();
246
+ int chunkStart, chunkEnd;
247
+ if (!rangeComputation (chunkStart, chunkEnd, rangeIteration, rangeBlocksCount, covisibility.size ()))
248
+ {
249
+ ALICEVISION_LOG_INFO (" Nothing to compute in this chunk" );
280
250
}
281
251
282
252
ALICEVISION_LOG_INFO (" A total of " << covisibility.size () << " pairs has to be processed." );
@@ -287,11 +257,11 @@ int aliceVision_main(int argc, char** argv)
287
257
288
258
ALICEVISION_LOG_INFO (" Process co-visibility" );
289
259
std::stringstream ss;
290
- ss << outputDirectory << " /pairs_" << rangeStart << " .json" ;
260
+ ss << outputDirectory << " /pairs_" << rangeIteration << " .json" ;
291
261
std::ofstream of (ss.str ());
292
262
293
263
// For each covisible pair
294
- #pragma omp parallel for
264
+ #pragma omp parallel for schedule(dynamic)
295
265
for (int posPairs = chunkStart; posPairs < chunkEnd; posPairs++)
296
266
{
297
267
auto iterPairs = covisibility.begin ();
@@ -311,6 +281,11 @@ int aliceVision_main(int argc, char** argv)
311
281
aliceVision::track::TracksMap mapTracksCommon;
312
282
track::getCommonTracksInImagesFast ({refImage, nextImage}, tracksHandler.getAllTracks (), tracksHandler.getTracksPerView (), mapTracksCommon);
313
283
284
+ if (mapTracksCommon.size () == 0 )
285
+ {
286
+ continue ;
287
+ }
288
+
314
289
// Build features coordinates matrices
315
290
const std::size_t n = mapTracksCommon.size ();
316
291
std::vector<Eigen::Vector2d> refpts, nextpts;
0 commit comments