|
@@ -1,7 +1,7 @@
|
|
|
/**
|
|
|
* @file LocalFeatureSift.cpp
|
|
|
* @brief local feature with sift
|
|
|
-* @author Erik Rodner
|
|
|
+* @author Erik Rodner, Alexander Freytag
|
|
|
* @date 03/10/2012
|
|
|
*/
|
|
|
#include <iostream>
|
|
@@ -14,28 +14,52 @@ using namespace OBJREC;
|
|
|
using namespace std;
|
|
|
using namespace NICE;
|
|
|
|
|
|
-LocalFeatureSift::LocalFeatureSift( const Config *conf )
|
|
|
+///////////////////// ///////////////////// /////////////////////
|
|
|
+// CONSTRUCTORS / DESTRUCTORS
|
|
|
+///////////////////// ///////////////////// /////////////////////
|
|
|
+
|
|
|
+LocalFeatureSift::LocalFeatureSift() : LocalFeature ()
|
|
|
+{
|
|
|
+ this->octaves = 6;
|
|
|
+ this->levels = 3;
|
|
|
+ this->first_octave = -1;
|
|
|
+ this->normalizeFeature = true;
|
|
|
+ this->magnif = 3;
|
|
|
+ this->deletemode = true;
|
|
|
+ this->integerValues = true;
|
|
|
+ this->usegpu = false;
|
|
|
+}
|
|
|
+
|
|
|
+LocalFeatureSift::LocalFeatureSift( const NICE::Config * _conf )
|
|
|
+{
|
|
|
+ this->initFromConfig( _conf );
|
|
|
+}
|
|
|
+
|
|
|
+LocalFeatureSift::~LocalFeatureSift()
|
|
|
{
|
|
|
- this->conf = conf;
|
|
|
+}
|
|
|
|
|
|
- octaves = conf->gI("LFSiftPP", "octaves", 6);
|
|
|
- levels = conf->gI("LFSiftPP", "levels", 3);
|
|
|
- first_octave = conf->gI("LFSiftPP", "first_octave", -1);
|
|
|
- normalizeFeature = conf->gB("LFSiftPP", "normalize_feature", true );
|
|
|
- magnif = conf->gD("LFSiftPP", "magnif", 3 );
|
|
|
- deletemode = conf->gB("LFSiftPP", "deletemode", true );
|
|
|
- integerValues = conf->gB("LFSiftPP", "integer_values", true );
|
|
|
+void OBJREC::LocalFeatureSift::initFromConfig( const NICE::Config* _conf, const std::string& _confSection )
|
|
|
+{
|
|
|
+ //NOTE previous confSection defaultet to LFSiftPP!
|
|
|
+ this->octaves = _conf->gI(_confSection, "octaves", 6);
|
|
|
+ this->levels = _conf->gI(_confSection, "levels", 3);
|
|
|
+ this->first_octave = _conf->gI(_confSection, "first_octave", -1);
|
|
|
+ this->normalizeFeature = _conf->gB(_confSection, "normalize_feature", true );
|
|
|
+ this->magnif = _conf->gD(_confSection, "magnif", 3 );
|
|
|
+ this->deletemode = _conf->gB(_confSection, "deletemode", true );
|
|
|
+ this->integerValues = _conf->gB(_confSection, "integer_values", true );
|
|
|
|
|
|
#ifdef NICE_USELIB_CUDASIFT
|
|
|
- usegpu = conf->gB("LFSiftPP", "use_siftgpu", false );
|
|
|
+ this->usegpu = _conf->gB(_confSection, "use_siftgpu", false );
|
|
|
#else
|
|
|
- usegpu = false;
|
|
|
+ this->usegpu = false;
|
|
|
#endif
|
|
|
}
|
|
|
|
|
|
-LocalFeatureSift::~LocalFeatureSift()
|
|
|
-{
|
|
|
-}
|
|
|
+///////////////////// ///////////////////// /////////////////////
|
|
|
+// FEATURE STUFF
|
|
|
+///////////////////// ///////////////////// //////////////////
|
|
|
|
|
|
void LocalFeatureSift::sortPositions(VVector & positions) const
|
|
|
{
|
|
@@ -297,3 +321,153 @@ void LocalFeatureSift::withGPU(const NICE::Image& img, VVector& positions, VVect
|
|
|
}
|
|
|
}
|
|
|
#endif
|
|
|
+
|
|
|
+///////////////////// INTERFACE PERSISTENT /////////////////////
|
|
|
+// interface specific methods for store and restore
|
|
|
+///////////////////// INTERFACE PERSISTENT /////////////////////
|
|
|
+
|
|
|
+void LocalFeatureSift::restore ( std::istream & is, int format )
|
|
|
+{
|
|
|
+ //delete everything we knew so far...
|
|
|
+ this->clear();
|
|
|
+
|
|
|
+
|
|
|
+ if ( is.good() )
|
|
|
+ {
|
|
|
+
|
|
|
+ std::string tmp;
|
|
|
+ is >> tmp; //class name
|
|
|
+
|
|
|
+ if ( ! this->isStartTag( tmp, "LocalFeatureSift" ) )
|
|
|
+ {
|
|
|
+ std::cerr << " WARNING - attempt to restore LocalFeatureSift, 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, "LocalFeatureSift" ) )
|
|
|
+ {
|
|
|
+ b_endOfBlock = true;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ tmp = this->removeStartTag ( tmp );
|
|
|
+
|
|
|
+ if ( tmp.compare("octaves") == 0 )
|
|
|
+ {
|
|
|
+ is >> this->octaves;
|
|
|
+ is >> tmp; // end of block
|
|
|
+ tmp = this->removeEndTag ( tmp );
|
|
|
+ }
|
|
|
+ else if ( tmp.compare("levels") == 0 )
|
|
|
+ {
|
|
|
+ is >> this->levels;
|
|
|
+ is >> tmp; // end of block
|
|
|
+ tmp = this->removeEndTag ( tmp );
|
|
|
+ }
|
|
|
+ else if ( tmp.compare("first_octave") == 0 )
|
|
|
+ {
|
|
|
+ is >> this->first_octave;
|
|
|
+ is >> tmp; // end of block
|
|
|
+ tmp = this->removeEndTag ( tmp );
|
|
|
+ }
|
|
|
+ else if ( tmp.compare("normalizeFeature") == 0 )
|
|
|
+ {
|
|
|
+ is >> this->normalizeFeature;
|
|
|
+ is >> tmp; // end of block
|
|
|
+ tmp = this->removeEndTag ( tmp );
|
|
|
+ }
|
|
|
+ else if ( tmp.compare("magnif") == 0 )
|
|
|
+ {
|
|
|
+ is >> this->magnif;
|
|
|
+ is >> tmp; // end of block
|
|
|
+ tmp = this->removeEndTag ( tmp );
|
|
|
+ }
|
|
|
+ else if ( tmp.compare("deletemode") == 0 )
|
|
|
+ {
|
|
|
+ is >> this->deletemode;
|
|
|
+ is >> tmp; // end of block
|
|
|
+ tmp = this->removeEndTag ( tmp );
|
|
|
+ }
|
|
|
+ else if ( tmp.compare("integerValues") == 0 )
|
|
|
+ {
|
|
|
+ is >> this->integerValues;
|
|
|
+ is >> tmp; // end of block
|
|
|
+ tmp = this->removeEndTag ( tmp );
|
|
|
+ }
|
|
|
+ else if ( tmp.compare("usegpu") == 0 )
|
|
|
+ {
|
|
|
+ is >> this->usegpu;
|
|
|
+ is >> tmp; // end of block
|
|
|
+ tmp = this->removeEndTag ( tmp );
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ std::cerr << "WARNING -- unexpected LocalFeatureSift object -- " << tmp << " -- for restoration... aborting" << std::endl;
|
|
|
+ throw;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ std::cerr << "LocalFeatureSift::restore -- InStream not initialized - restoring not possible!" << std::endl;
|
|
|
+ throw;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void LocalFeatureSift::store ( std::ostream & os, int format ) const
|
|
|
+{
|
|
|
+ if (os.good())
|
|
|
+ {
|
|
|
+ // show starting point
|
|
|
+ os << this->createStartTag( "LocalFeatureSift" ) << std::endl;
|
|
|
+
|
|
|
+ os << this->createStartTag( "octaves" ) << std::endl;
|
|
|
+ os << this->octaves << std::endl;
|
|
|
+ os << this->createEndTag( "octaves" ) << std::endl;
|
|
|
+
|
|
|
+ os << this->createStartTag( "levels" ) << std::endl;
|
|
|
+ os << this->levels << std::endl;
|
|
|
+ os << this->createEndTag( "levels" ) << std::endl;
|
|
|
+
|
|
|
+ os << this->createStartTag( "first_octave" ) << std::endl;
|
|
|
+ os << this->first_octave << std::endl;
|
|
|
+ os << this->createEndTag( "first_octave" ) << std::endl;
|
|
|
+
|
|
|
+ os << this->createStartTag( "normalizeFeature" ) << std::endl;
|
|
|
+ os << this->normalizeFeature << std::endl;
|
|
|
+ os << this->createEndTag( "normalizeFeature" ) << std::endl;
|
|
|
+
|
|
|
+ os << this->createStartTag( "magnif" ) << std::endl;
|
|
|
+ os << this->magnif << std::endl;
|
|
|
+ os << this->createEndTag( "magnif" ) << std::endl;
|
|
|
+
|
|
|
+ os << this->createStartTag( "deletemode" ) << std::endl;
|
|
|
+ os << this->deletemode << std::endl;
|
|
|
+ os << this->createEndTag( "deletemode" ) << std::endl;
|
|
|
+
|
|
|
+ os << this->createStartTag( "integerValues" ) << std::endl;
|
|
|
+ os << this->integerValues << std::endl;
|
|
|
+ os << this->createEndTag( "integerValues" ) << std::endl;
|
|
|
+
|
|
|
+ os << this->createStartTag( "usegpu" ) << std::endl;
|
|
|
+ os << this->usegpu << std::endl;
|
|
|
+ os << this->createEndTag( "usegpu" ) << std::endl;
|
|
|
+
|
|
|
+ // done
|
|
|
+ os << this->createEndTag( "LocalFeatureSift" ) << std::endl;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ std::cerr << "OutStream not initialized - storing not possible!" << std::endl;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void LocalFeatureSift::clear ()
|
|
|
+{
|
|
|
+}
|