|
@@ -2,6 +2,7 @@
|
|
|
#include <fstream>
|
|
|
#include <iostream>
|
|
|
#include <exception>
|
|
|
+#include <stdlib.h> /* used for getenv */
|
|
|
|
|
|
// nice-vislearning includes
|
|
|
#include "vislearning/baselib/ColorSpace.h"
|
|
@@ -38,38 +39,18 @@ LocalFeatureColorWeijer::LocalFeatureColorWeijer( const Config *c )
|
|
|
|
|
|
this->tfile = this->conf->gS( "LocalFeatureColorWeijer", "table", "");
|
|
|
|
|
|
+ // 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
|
|
|
+ // NOTE This will only work if NICEHOME is set in your environment (e.g., by exporting it in your bashrc)
|
|
|
if ( this->tfile.compare("") == 0 )
|
|
|
{
|
|
|
- // call echo $NICEHOME on a shell and capture the result
|
|
|
- // if NICEHOME is set in your environment, we can use this to
|
|
|
- // get the correct place to look for the settings...
|
|
|
- FILE* pipe = popen("echo $NICEHOME", "r");
|
|
|
+ char* pNICEHOME;
|
|
|
+ pNICEHOME = getenv ("NICEHOME");
|
|
|
|
|
|
- if ( !pipe )
|
|
|
+ if ( pNICEHOME != NULL )
|
|
|
{
|
|
|
- // error in reading system call result
|
|
|
- // we do not output any error here, but throw an Exception lateron
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- char buffer[128];
|
|
|
- std::string s_NICEHOME = "";
|
|
|
-
|
|
|
- while( !feof(pipe) )
|
|
|
- {
|
|
|
- if(fgets(buffer, 128, pipe) != NULL)
|
|
|
- s_NICEHOME += buffer;
|
|
|
- }
|
|
|
- pclose(pipe);
|
|
|
-
|
|
|
- if ( s_NICEHOME.length() <= 1 )
|
|
|
- {
|
|
|
- // NICEHOME is not set as enviromental variable
|
|
|
- // this will produce an Exception lateron since no LUT file can be read
|
|
|
- this->tfile = "";
|
|
|
- }
|
|
|
- else
|
|
|
- this->tfile = s_NICEHOME + "/vislearning/features/localfeatures/input/colorWeijer/w2c.txt";
|
|
|
+ this->tfile = std::string ( pNICEHOME );
|
|
|
+ this->tfile += "/vislearning/features/localfeatures/input/colorWeijer/w2c.txt";
|
|
|
}
|
|
|
}
|
|
|
|