Commit 2d62784a authored by Gaetano Raffaele's avatar Gaetano Raffaele
Browse files

ENH: Reworking resume option

parent 5156e977
......@@ -120,9 +120,9 @@ private:
AddParameter(ParameterType_Int, "resumetilecol", "Starting tile column in resume mode");
SetDefaultParameterInt("resumetilerow", 0);
SetDefaultParameterInt("resumetilecol", 0);
//MandatoryOff("resume");
//MandatoryOff("resume.tilex");
//MandatoryOff("resume.tiley");
MandatoryOff("resume");
MandatoryOff("resumetilerow");
MandatoryOff("resumetilecol");
}
void DoUpdateParameters()
......
......@@ -95,7 +95,6 @@ void Controller<TSegmenter>::RunSegmentation()
// temp. patch, maybe calculate real current memory after resuming graphs.
long long unsigned int accumulatedMemory = 2 * m_Memory;
if (!m_Resuming) {
accumulatedMemory = RunFirstPartialSegmentation<TSegmenter>(
m_InputImage,
m_SpecificParameters,
......@@ -107,10 +106,8 @@ void Controller<TSegmenter>::RunSegmentation()
m_NbTilesY,
m_TileWidth,
m_TileHeight,
isFusion);
} else {
isFusion = true;
}
isFusion,
m_Resuming);
#ifdef OTB_USE_MPI
GatherUsefulVariables(accumulatedMemory, isFusion);
......
......@@ -2,11 +2,18 @@
#define __LSGRM_GRAPH_OPERATIONS_TXX
//#include "lsgrmGraphOperations.h"
//#include <unistd.h>
#include <fstream>
#include <cstdio>
namespace lsgrm
{
bool file_exists(const std::string& fileName)
{
std::ifstream infile(fileName.c_str());
return infile.good();
}
template<class TSegmenter>
typename TSegmenter::ImageType::Pointer ReadImageRegion(
typename TSegmenter::ImageType * inputPtr,
......@@ -640,7 +647,8 @@ long long unsigned int RunFirstPartialSegmentation(
const unsigned int nbTilesY,
const unsigned int tileWidth,
const unsigned int tileHeight,
bool& isFusion)
bool& isFusion,
bool resume)
{
using ImageType = typename TSegmenter::ImageType;
......@@ -664,6 +672,19 @@ long long unsigned int RunFirstPartialSegmentation(
{
// Reading images
ProcessingTile currentTile = tiles[row*nbTilesX + col];
if (resume && file_exists(currentTile.nodeFileName) && file_exists(currentTile.edgeFileName))
{
std::cout << "\tResuming graph..." << std::endl;
TSegmenter segmenter;
ReadGraph<TSegmenter>(segmenter.m_Graph, currentTile.nodeFileName, currentTile.edgeFileName);
// Retrieve the amount of memory to store this graph
std::cout << "\tGet graph memory..." << std::endl;
accumulatedMemory += segmenter.GetGraphMemory();
if(segmenter.GetComplete() == false)
isFusion = true;
continue;
}
std::cout << "Processing tile " << (row*nbTilesX + col) << " / " << (nbTilesX*nbTilesY) <<
" (" << col << ", " << row << ")" <<
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment