Explorar o código

added support for relative file/path names in MultiDataset and filelists. In case of a relative path, make it absolute with respect to the config's directory

Johannes Ruehle %!s(int64=11) %!d(string=hai) anos
pai
achega
e21f44edaa

+ 2 - 0
cbaselib/LabeledFileList.cpp

@@ -244,6 +244,8 @@ void LabeledFileList::getFromList (
 
     if ( ! ( ifs >> file ) ) break;
 
+    file = datasetconf.getAbsoluteFilenameRelativeToThisConfig(file);
+
     if ( classnames.existsClassCode ( classcode ) ) {
       int classno = classnames.classno ( classcode );
 

+ 13 - 1
cbaselib/MultiDataset.cpp

@@ -21,6 +21,7 @@
 
 #include "core/basics/StringTools.h"
 #include "core/basics/FileMgt.h"
+#include "core/basics/FileName.h"
 
 #include "vislearning/cbaselib/MultiDataset.h"
 
@@ -183,7 +184,18 @@ MultiDataset::MultiDataset( const Config *conf , LabeledSetFactory *pSetFactory)
 #ifdef DEBUG_MultiDataset
       fprintf (stderr, "Reading dataset config for block [%s]\n", i->c_str() );
 #endif
-      Config dsconf ( (dataset + "/dataset.conf").c_str() );
+      NICE::FileName t_ConfigFilename( conf->getFilename() );
+      NICE::FileName t_DatasetFilename( dataset );
+
+      // check for relative path correction:
+      // if dataset is a relative path, then make it absolute using the
+      // given config's directory
+      if( t_DatasetFilename.isRelative() )
+      {
+          dataset = t_ConfigFilename.extractPath().str() + dataset;
+      }
+      std::string sDatasetConfFilename =  dataset + "/dataset.conf";
+      Config dsconf ( sDatasetConfFilename.c_str() );
 
       dirs[*i] = dataset;
       dsconfs[*i] = dsconf;

+ 1 - 0
features/localfeatures/LocalFeatureColorWeijer.cpp

@@ -55,6 +55,7 @@ void LocalFeatureColorWeijer::initFromConfig ( const NICE::Config * _conf, const
 {
 
   this->tfile = _conf->gS( "LocalFeatureColorWeijer", "table", "");
+  this->tfile = _conf->getAbsoluteFilenameRelativeToThisConfig( tfile );
   
   // If no destination  to the LUT was given, we try to use the file shipped with this library
   // Therefore, we try to catch the NICEHOME and if possible, append the location where the LUT file is stored