|
@@ -32,12 +32,25 @@ const int colors[11][3] =
|
|
{255, 255, 0}, // yellow
|
|
{255, 255, 0}, // yellow
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+OBJREC::LocalFeatureColorWeijer::LocalFeatureColorWeijer()
|
|
|
|
+{
|
|
|
|
+ this->tfile = "";
|
|
|
|
+}
|
|
|
|
|
|
-LocalFeatureColorWeijer::LocalFeatureColorWeijer( const Config *c )
|
|
|
|
|
|
+
|
|
|
|
+LocalFeatureColorWeijer::LocalFeatureColorWeijer( const NICE::Config *_conf )
|
|
{
|
|
{
|
|
- this->conf = c;
|
|
|
|
|
|
+ this->initFromConfig ( _conf );
|
|
|
|
+}
|
|
|
|
|
|
- this->tfile = this->conf->gS( "LocalFeatureColorWeijer", "table", "");
|
|
|
|
|
|
+LocalFeatureColorWeijer::~LocalFeatureColorWeijer()
|
|
|
|
+{
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void LocalFeatureColorWeijer::initFromConfig ( const NICE::Config * _conf, const std::string & _confSection )
|
|
|
|
+{
|
|
|
|
+
|
|
|
|
+ this->tfile = _conf->gS( "LocalFeatureColorWeijer", "table", "");
|
|
|
|
|
|
// If no destination to the LUT was given, we try to use the file shipped with this library
|
|
// 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
|
|
// Therefore, we try to catch the NICEHOME and if possible, append the location where the LUT file is stored
|
|
@@ -54,11 +67,7 @@ LocalFeatureColorWeijer::LocalFeatureColorWeijer( const Config *c )
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- this->restore();
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-LocalFeatureColorWeijer::~LocalFeatureColorWeijer()
|
|
|
|
-{
|
|
|
|
|
|
+ this->restoreLUT();
|
|
}
|
|
}
|
|
|
|
|
|
int LocalFeatureColorWeijer::getDescSize() const
|
|
int LocalFeatureColorWeijer::getDescSize() const
|
|
@@ -66,7 +75,7 @@ int LocalFeatureColorWeijer::getDescSize() const
|
|
return LASTCOLOR;
|
|
return LASTCOLOR;
|
|
}
|
|
}
|
|
|
|
|
|
-void LocalFeatureColorWeijer::restore()
|
|
|
|
|
|
+void LocalFeatureColorWeijer::restoreLUT()
|
|
{
|
|
{
|
|
ifstream fin( this->tfile.c_str() );
|
|
ifstream fin( this->tfile.c_str() );
|
|
if( !fin.is_open() )
|
|
if( !fin.is_open() )
|
|
@@ -74,7 +83,7 @@ void LocalFeatureColorWeijer::restore()
|
|
fthrow(Exception,"ColorWeijer: could not find lookup table file. Specify the path in the config, e.g., YOURNICEHOME/vislearning/features/localfeatures/input/colorWeijer/w2c.txt");
|
|
fthrow(Exception,"ColorWeijer: could not find lookup table file. Specify the path in the config, e.g., YOURNICEHOME/vislearning/features/localfeatures/input/colorWeijer/w2c.txt");
|
|
}
|
|
}
|
|
|
|
|
|
- while(!fin.eof())
|
|
|
|
|
|
+ while( !fin.eof() )
|
|
{
|
|
{
|
|
double rd,gd,bd;
|
|
double rd,gd,bd;
|
|
int r,g,b;
|
|
int r,g,b;
|
|
@@ -115,9 +124,6 @@ int LocalFeatureColorWeijer::getDescriptors( const NICE::Image & img, VVector &
|
|
|
|
|
|
int LocalFeatureColorWeijer::getDescriptors( const NICE::ColorImage & img, VVector & positions, VVector & features ) const
|
|
int LocalFeatureColorWeijer::getDescriptors( const NICE::ColorImage & img, VVector & positions, VVector & features ) const
|
|
{
|
|
{
|
|
- int width = ( int )img.width();
|
|
|
|
- int height = ( int )img.height();
|
|
|
|
-
|
|
|
|
for ( int j = 0; j < ( int )positions.size(); j++ )
|
|
for ( int j = 0; j < ( int )positions.size(); j++ )
|
|
{
|
|
{
|
|
int x = positions[j][0];
|
|
int x = positions[j][0];
|
|
@@ -126,7 +132,7 @@ int LocalFeatureColorWeijer::getDescriptors( const NICE::ColorImage & img, VVect
|
|
int g = img(x,y,1)/8;
|
|
int g = img(x,y,1)/8;
|
|
int b = img(x,y,2)/8;
|
|
int b = img(x,y,2)/8;
|
|
|
|
|
|
- Vector feat( 11 );
|
|
|
|
|
|
+ NICE::Vector feat( 11 );
|
|
for ( uint i = 0; i < 11; i++ )
|
|
for ( uint i = 0; i < 11; i++ )
|
|
{
|
|
{
|
|
feat[i] = hist[r][g][b][i];
|
|
feat[i] = hist[r][g][b][i];
|
|
@@ -268,3 +274,98 @@ void LocalFeatureColorWeijer::getFeats( const ColorImage &img, MultiChannelImage
|
|
|
|
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+///////////////////// INTERFACE PERSISTENT /////////////////////
|
|
|
|
+// interface specific methods for store and restore
|
|
|
|
+///////////////////// INTERFACE PERSISTENT /////////////////////
|
|
|
|
+
|
|
|
|
+void LocalFeatureColorWeijer::restore ( std::istream & is, int format )
|
|
|
|
+{
|
|
|
|
+ //delete everything we knew so far...
|
|
|
|
+ this->clear();
|
|
|
|
+
|
|
|
|
+ bool b_restoreVerbose ( false );
|
|
|
|
+#ifdef B_RESTOREVERBOSE
|
|
|
|
+ b_restoreVerbose = true;
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+ if ( is.good() )
|
|
|
|
+ {
|
|
|
|
+ if ( b_restoreVerbose )
|
|
|
|
+ std::cerr << " restore LocalFeatureColorWeijer" << std::endl;
|
|
|
|
+
|
|
|
|
+ std::string tmp;
|
|
|
|
+ is >> tmp; //class name
|
|
|
|
+
|
|
|
|
+ if ( ! this->isStartTag( tmp, "LocalFeatureColorWeijer" ) )
|
|
|
|
+ {
|
|
|
|
+ std::cerr << " WARNING - attempt to restore LocalFeatureColorWeijer, but start flag " << tmp << " does not match! Aborting... " << std::endl;
|
|
|
|
+ throw;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ bool b_endOfBlock ( false ) ;
|
|
|
|
+
|
|
|
|
+ while ( !b_endOfBlock )
|
|
|
|
+ {
|
|
|
|
+ is >> tmp; // start of block
|
|
|
|
+
|
|
|
|
+ if ( this->isEndTag( tmp, "LocalFeatureColorWeijer" ) )
|
|
|
|
+ {
|
|
|
|
+ b_endOfBlock = true;
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ tmp = this->removeStartTag ( tmp );
|
|
|
|
+
|
|
|
|
+ if ( b_restoreVerbose )
|
|
|
|
+ std::cerr << " currently restore section " << tmp << " in LocalFeatureColorWeijer" << std::endl;
|
|
|
|
+
|
|
|
|
+ if ( tmp.compare("tfile") == 0 )
|
|
|
|
+ {
|
|
|
|
+ is >> this->tfile;
|
|
|
|
+ is >> tmp; // end of block
|
|
|
|
+ tmp = this->removeEndTag ( tmp );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ std::cerr << "WARNING -- unexpected LocalFeatureColorWeijer object -- " << tmp << " -- for restoration... aborting" << std::endl;
|
|
|
|
+ throw;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ std::cerr << "LocalFeatureColorWeijer::restore -- InStream not initialized - restoring not possible!" << std::endl;
|
|
|
|
+ throw;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // try to load the LUT from a separate external file
|
|
|
|
+ //NOTE we could also think about adding the LUT into the store/restore process. However, the table is BIG, so it would
|
|
|
|
+ // blow up whole outfile
|
|
|
|
+ this->restoreLUT ( ) ;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void LocalFeatureColorWeijer::store ( std::ostream & os, int format ) const
|
|
|
|
+{
|
|
|
|
+ if (os.good())
|
|
|
|
+ {
|
|
|
|
+ // show starting point
|
|
|
|
+ os << this->createStartTag( "LocalFeatureColorWeijer" ) << std::endl;
|
|
|
|
+
|
|
|
|
+ os << this->createStartTag( "tfile" ) << std::endl;
|
|
|
|
+ os << this->tfile << std::endl;
|
|
|
|
+ os << this->createEndTag( "tfile" ) << std::endl;
|
|
|
|
+
|
|
|
|
+ // done
|
|
|
|
+ os << this->createEndTag( "LocalFeatureColorWeijer" ) << std::endl;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ std::cerr << "OutStream not initialized - storing not possible!" << std::endl;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void LocalFeatureColorWeijer::clear ()
|
|
|
|
+{
|
|
|
|
+ //TODO
|
|
|
|
+}
|