| 312 | |
| 313 | template<typename T> |
| 314 | void 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()); |
no test coverage detected