MCPcopy Create free account
hub / github.com/alicevision/AliceVision / readMapFromFileOrTiles

Function readMapFromFileOrTiles

src/aliceVision/mvsUtils/mapIO.cpp:314–400  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

312
313template<typename T>
314void readMapFromFileOrTiles(int rc,
315 const MultiViewParams& mp,
316 EFileType fileType,
317 image::Image<T>& out_map,
318 int scale,
319 int step,
320 const std::string& customSuffix)
321{
322 // assert scale & step
323 assert(scale > 0);
324 assert(step > 0);
325
326 // single file fullsize map path
327 const std::string mapPath = getFileNameFromIndex(mp, rc, fileType, customSuffix);
328
329 // check single file fullsize map exists
330 if (utils::exists(mapPath))
331 {
332 ALICEVISION_LOG_TRACE("Load depth map (full image): " << mapPath << ", scale: " << scale << ", step: " << step);
333 // read single file fullsize map
334 image::readImage(mapPath, out_map, image::EImageColorSpace::NO_CONVERSION);
335 return;
336 }
337 ALICEVISION_LOG_TRACE("No full image depth map: " << mapPath << ", scale: " << scale << ", step: " << step << ". Looking for tiles.");
338
339 // read map from tiles
340 const ROI imageRoi(Range(0, mp.getWidth(rc)), Range(0, mp.getHeight(rc)));
341
342 const int scaleStep = scale * step;
343 const int width = divideRoundUp(mp.getWidth(rc), scaleStep);
344 const int height = divideRoundUp(mp.getHeight(rc), scaleStep);
345
346 // the output full map
347 out_map.resize(width, height, true, T(0.f)); // should be initialized, additive process
348
349 // get tile map path list for the given R camera
350 std::vector<std::string> mapTilePathList;
351 getTilePathList(rc, mp, fileType, customSuffix, mapTilePathList);
352
353 if (mapTilePathList.empty())
354 {
355 // map can be empty
356 ALICEVISION_LOG_INFO("Cannot find any " << getMapNameFromFileType(fileType) << " tile file (rc: " << rc << ").");
357 return; // nothing to do, already initialized
358 }
359 else
360 {
361 ALICEVISION_LOG_TRACE("Load depth map from " << mapTilePathList.size() << " tiles. First tile: " << mapTilePathList[0] << ", scale: " << scale
362 << ", step: " << step);
363 }
364
365 // get tileParams from first tile file metadata
366 TileParams tileParams;
367 getTileParamsFromMetadata(mapTilePathList.front(), tileParams);
368
369 // get tile roi list from each file metadata
370 std::vector<ROI> tileRoiList;
371 tileRoiList.resize(mapTilePathList.size());

Callers 1

readMapFunction · 0.85

Calls 15

getFileNameFromIndexFunction · 0.85
existsFunction · 0.85
readImageFunction · 0.85
RangeClass · 0.85
divideRoundUpFunction · 0.85
getTilePathListFunction · 0.85
getMapNameFromFileTypeFunction · 0.85
getRoiFromMetadataFunction · 0.85
intersectFunction · 0.85
addSingleTileMapWeightedFunction · 0.85
pathClass · 0.85

Tested by

no test coverage detected