فهرست منبع

towards persistent version of LocalFeatureRepresentation

Alexander Freytag 11 سال پیش
والد
کامیت
39d2734fbd

+ 191 - 31
features/localfeatures/LFColorSande.cpp

@@ -1,41 +1,69 @@
 /**
 * @file LFColorSande.cpp
 * @brief interface to ColorSande implementation
-* @author Erik Rodner
+* @author Erik Rodner, Alexander Freytag
 * @date 11/19/2007
-
 */
+
+// STL includes
 #include <errno.h>
 #include <iostream>
+#include <sstream>
 
+// nice-core includes
+#include <core/basics/StringTools.h>
+#include <core/basics/FileMgt.h>
+// 
 #include <core/image/Convert.h>
 
-#include "core/basics/StringTools.h"
-#include "core/basics/FileMgt.h"
-#include "vislearning/baselib/Globals.h"
-
-#include "vislearning/features/localfeatures/LFColorSande.h"
+// nice-vislearning includes
+#include <vislearning/baselib/Globals.h>
+// 
+#include "LFColorSande.h"
 
 
 #define DESCSIZE_DUMMY "/home/bachi/HiWi/nice/nice/objrec-froehlichexp/progs/IMG_8762.JPG"
 
-#include <sstream>
 
-using namespace OBJREC;
 
+using namespace OBJREC;
 using namespace std;
 using namespace NICE;
 
+///////////////////// ///////////////////// /////////////////////
+//                   CONSTRUCTORS / DESTRUCTORS
+///////////////////// ///////////////////// /////////////////
 
-
-LFColorSande::LFColorSande ( const Config *conf, std::string section )
+LFColorSande::LFColorSande() : LocalFeatureRepresentation () 
 {
-  std::cerr << "LF COLOR SANDE SECTION ====================== :" << section << ":"<<std::endl;
+  this->c_binaryExecutable = "";
+  this->c_params           = "--descriptor opponentsift";
+  this->scales             = "1+1.5+3.0+4.5+6";
+  this->descriptor_size    = -1;
+  this->usegrid            = false;
   
+  int gridsizeInt             = 5;
+  std::ostringstream temp;
+  temp << gridsizeInt;
+  this->gridsize = temp.str(); 
+}
+
+LFColorSande::LFColorSande ( const NICE::Config * _conf, std::string _confSection )
+{
+ 
+  this->initFromConfig( _conf );
+}
+
+LFColorSande::~LFColorSande()
+{
+}
+
+void LFColorSande::initFromConfig(const NICE::Config * _conf, const std::string & _confSection)
+{
   try
   {
     //a possible location on dbv could be: "/home/bachi/libs/van_de_sande/x86_64-linux-gcc/colorDescriptor" );
-    c_binaryExecutable = conf->gS ( section, "binaryExecutable" /*we do not add a default here, this has to adapted to your system!!!*/); 
+    this->c_binaryExecutable = _conf->gS ( _confSection, "binaryExecutable" /*we do not add a default here, this has to adapted to your system!!!*/); 
   }
   catch (NICE::Exception exception )
   {
@@ -43,43 +71,44 @@ LFColorSande::LFColorSande ( const Config *conf, std::string section )
     throw exception;
   }
 
-  c_params = conf->gS ( section, "params", "--descriptor opponentsift" );
-  scales = conf->gS ( section, "scales", "1+1.5+3.0+4.5+6" );
-  std::cerr << "scales: " << scales << std::endl;
-
-  descriptor_size = conf->gI ( section, "descriptor_size", -1 );
+  this->c_params        = _conf->gS ( _confSection, "params", "--descriptor opponentsift" );
+  this->scales          = _conf->gS ( _confSection, "scales", "1+1.5+3.0+4.5+6" );
+  this->descriptor_size = _conf->gI ( _confSection, "descriptor_size", -1 );
+  this->usegrid         = _conf->gB ( _confSection, "usegrid", false );
 
-  usegrid = conf->gB ( section, "usegrid", false );
-
-  int g = conf->gI ( section, "grid", 5 );
+  int gridsizeInt = _conf->gI ( _confSection, "grid", 5 );
   std::ostringstream temp;
-  temp << g;
-  gridsize = temp.str();
+  temp << gridsizeInt;
+  this->gridsize        = temp.str();
   
   if ( descriptor_size <= 0 )
   {
     fprintf ( stderr, "LFColorSande::LFColorSande: No descriptor size found in config -> self test\n" );
+    
     /** get feature dimension **/
     NICE::Image testimg ( DESCSIZE_DUMMY );
-    VVector features;
-    VVector positions;
-    extractFeatures ( testimg, features, positions );
+    NICE::VVector features;
+    NICE::VVector positions;
+    
+    this->extractFeatures ( testimg, features, positions );
+    
     if ( features.size() <= 0 )
       fthrow ( Exception, "No features found in " << DESCSIZE_DUMMY << " picture." );
-    descriptor_size = features[0].size();
+    this->descriptor_size = features[0].size();
 
     fprintf ( stderr, "LFColorSande::LFColorSande Self Test features:%d dimension:%d\n", ( int ) features.size(), descriptor_size );
   }
   
-  if ( descriptor_size != conf->gI ( "features", "descriptor_size", descriptor_size ) )
+  if ( descriptor_size != _conf->gI ( "features", "descriptor_size", descriptor_size ) )
   {
     cerr << "Warning: LFColorSande: descriptor sizes do not match !!!" << endl;
   }  
 }
 
-LFColorSande::~LFColorSande()
-{
-}
+
+///////////////////// ///////////////////// /////////////////////
+//                      FEATURE STUFF
+///////////////////// ///////////////////// ////////////////// 
 
 int LFColorSande::getDescSize () const
 {
@@ -280,3 +309,134 @@ int LFColorSande::extractFeatures ( const NICE::ColorImage & img, VVector & feat
 
   return 0;
 }
+
+///////////////////// INTERFACE PERSISTENT /////////////////////
+// interface specific methods for store and restore
+///////////////////// INTERFACE PERSISTENT ///////////////////// 
+
+void LFColorSande::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, "LFColorSande" ) )
+    {
+      std::cerr << " WARNING - attempt to restore LFColorSande, 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, "LFColorSande" ) )
+      {
+        b_endOfBlock = true;
+        continue;
+      }      
+      
+      tmp = this->removeStartTag ( tmp );     
+      
+      if ( tmp.compare("c_binaryExecutable") == 0 )
+      {
+        is >> this->c_binaryExecutable;
+        is >> tmp; // end of block 
+        tmp = this->removeEndTag ( tmp );
+      }
+      else if ( tmp.compare("c_params") == 0 )
+      {
+        is >> this->c_params;
+        is >> tmp; // end of block 
+        tmp = this->removeEndTag ( tmp );
+      }      
+      else if ( tmp.compare("scales") == 0 )
+      {
+        is >> this->scales;
+        is >> tmp; // end of block 
+        tmp = this->removeEndTag ( tmp );
+      }
+      else if ( tmp.compare("descriptor_size") == 0 )
+      {
+        is >> this->descriptor_size;
+        is >> tmp; // end of block 
+        tmp = this->removeEndTag ( tmp );
+      }      
+      else if ( tmp.compare("usegrid") == 0 )
+      {
+        is >> this->usegrid;
+        is >> tmp; // end of block 
+        tmp = this->removeEndTag ( tmp );
+      }
+      else if ( tmp.compare("gridsize") == 0 )
+      {
+        is >> this->gridsize;
+        is >> tmp; // end of block 
+        tmp = this->removeEndTag ( tmp );
+      }     
+      else
+      {
+      std::cerr << "WARNING -- unexpected LFColorSande object -- " << tmp << " -- for restoration... aborting" << std::endl;
+      throw;
+      }
+    }
+  }
+  else
+  {
+    std::cerr << "LFColorSande::restore -- InStream not initialized - restoring not possible!" << std::endl;
+    throw;
+  }
+}
+
+void LFColorSande::store ( std::ostream & os, int format ) const
+{ 
+  if (os.good())
+  {
+    // show starting point
+    os << this->createStartTag( "LFColorSande" ) << std::endl; 
+
+    
+    os << this->createStartTag( "c_binaryExecutable" ) << std::endl;
+    os << this->c_binaryExecutable << std::endl;
+    os << this->createEndTag( "c_binaryExecutable" ) << std::endl;  
+
+    os << this->createStartTag( "c_params" ) << std::endl;
+    os << this->c_params << std::endl;
+    os << this->createEndTag( "c_params" ) << std::endl;
+    
+    os << this->createStartTag( "scales" ) << std::endl;
+    os << this->scales << std::endl;
+    os << this->createEndTag( "scales" ) << std::endl;  
+
+    os << this->createStartTag( "descriptor_size" ) << std::endl;
+    os << this->descriptor_size << std::endl;
+    os << this->createEndTag( "descriptor_size" ) << std::endl; 
+    
+    os << this->createStartTag( "usegrid" ) << std::endl;
+    os << this->usegrid << std::endl;
+    os << this->createEndTag( "usegrid" ) << std::endl;
+    
+    os << this->createStartTag( "gridsize" ) << std::endl;
+    os << this->gridsize << std::endl;
+    os << this->createEndTag( "gridsize" ) << std::endl;     
+    
+    // done
+    os << this->createEndTag( "LFColorSande" ) << std::endl;    
+  }
+  else
+  {
+    std::cerr << "OutStream not initialized - storing not possible!" << std::endl;
+  }
+}
+
+void LFColorSande::clear ()
+{
+}

+ 74 - 10
features/localfeatures/LFColorSande.h

@@ -1,19 +1,24 @@
 /**
 * @file LFColorSande.h
 * @brief interface to ColorSande implementation
-* @author Erik Rodner
+* @author Erik Rodner, Alexander Freytag
 * @date 11/19/2007
 
 */
 #ifndef LFColorSandeINCLUDE
 #define LFColorSandeINCLUDE
 
-#include "core/vector/VectorT.h"
-#include "core/vector/MatrixT.h"
-#include "core/image/ImageT.h"
+// nice-core includes
+#include <core/basics/Config.h>
+// 
+#include <core/image/ImageT.h>
+// 
+#include <core/vector/VectorT.h>
+#include <core/vector/MatrixT.h>
 
+// nice-vislearning includes
 #include "LocalFeatureRepresentation.h"
-#include "core/basics/Config.h"
+
 
 
 namespace OBJREC {
@@ -23,9 +28,19 @@ class LFColorSande : public LocalFeatureRepresentation
 {
 
   protected:
+    
+    /////////////////////////
+    /////////////////////////
+    // PROTECTED VARIABLES //
+    /////////////////////////
+    /////////////////////////    
+    
     std::string c_binaryExecutable;
+
     std::string c_params;
-    double c_minScale;
+
+    //! used scales
+    std::string scales;
 
     //! size of the descriptor
     int descriptor_size;
@@ -36,16 +51,40 @@ class LFColorSande : public LocalFeatureRepresentation
     //! size of the grid
     std::string gridsize;
 
-    //! used scales
-    std::string scales;
+
+//     double c_minScale;
 
   public:
+    
+    ///////////////////// ///////////////////// /////////////////////
+    //                   CONSTRUCTORS / DESTRUCTORS
+    ///////////////////// ///////////////////// /////////////////////   
+    
+    /** 
+     * @brief default constructor
+     * @date 10-02-2014 (dd-mm-yyyy )
+     * @author Alexander Freytag
+     */
+    LFColorSande ( );     
 
-    /** simple constructor */
-    LFColorSande ( const NICE::Config *conf, std::string section = "LFColorSande" );
+    /** 
+     * @brief simple constructor 
+     */
+    LFColorSande ( const NICE::Config * _conf, std::string _confSection = "LFColorSande" );
 
     /** simple destructor */
     virtual ~LFColorSande();
+    
+    /** 
+     * @brief Jobs previously performed in the config-version of the constructor, read settings etc.
+     * @author Alexander Freytag
+     * @date 10-02-2014 ( dd-mm-yyyy )
+     */    
+    void initFromConfig ( const NICE::Config * _conf, const std::string & _confSection = "LFColorSande");     
+    
+    ///////////////////// ///////////////////// /////////////////////
+    //                      FEATURE STUFF
+    ///////////////////// ///////////////////// //////////////////            
 
     int getDescSize () const;
 
@@ -68,6 +107,31 @@ class LFColorSande : public LocalFeatureRepresentation
      */
     int extractFeatures ( const NICE::ColorImage & img, NICE::VVector & features,
                           NICE::VVector & positions ) const;
+                          
+    ///////////////////// INTERFACE PERSISTENT /////////////////////
+    // interface specific methods for store and restore
+    ///////////////////// INTERFACE PERSISTENT /////////////////////   
+    
+    /** 
+     * @brief Load object from external file (stream)
+     * @author Alexander Freytag
+     * @date 10-02-2014 ( dd-mmyyyy)
+     */     
+    virtual void restore ( std::istream & is, int format = 0 );
+    
+    /** 
+     * @brief Save object to external file (stream)
+     * @author Alexander Freytag
+     * @date 10-02-2014 ( dd-mmyyyy)
+     */       
+    virtual void store( std::ostream & os, int format = 0 ) const;
+    
+    /** 
+     * @brief Clear  object
+     * @author Alexander Freytag
+     * @date 10-02-2014 ( dd-mmyyyy)
+     */    
+    virtual void clear ();                            
 
 };
 

+ 242 - 27
features/localfeatures/LFSiftPP.cpp

@@ -1,70 +1,101 @@
 /** 
 * @file LFSiftPP.cpp
 * @brief Sift++ interface
-* @author Erik Rodner
+* @author Erik Rodner, Alexander Freytag
 * @date 11/19/2007
-
 */
+
+// STL includes
 #include <iostream>
 #include <sstream>
 
+// nice-core includes
+#include <core/basics/Exception.h>
+
 // #ifdef NICE_USELIB_ICE
 //   #include <image_nonvis.h>
 // #endif
+
+// nice-vislearning includes
 #include "vislearning/features/localfeatures/LFSiftPP.h"
 
-#include "core/basics/Exception.h"
+//TODO move this to separate input or source folder
+#include "vislearning/features/localfeatures/sift.h"
 
 
 using namespace std;
-
 using namespace NICE;
+using namespace OBJREC;
 
+///////////////////// ///////////////////// /////////////////////
+//                   CONSTRUCTORS / DESTRUCTORS
+///////////////////// ///////////////////// /////////////////
 
+LFSiftPP::LFSiftPP() : LocalFeatureRepresentation () 
+{
+    this->threshold        = 0.0;
+    this->edgeThreshold    = 10.0;
+    this->octaves          = 6;
+    this->first_octave     = -1;
+    this->levels           = 3;
+    
+    this->minScale         = 1;
+    this->maxScale         = 4;
+    this->numScales        = 10;
+    this->numAngles        = 6;
+    
+    this->descriptorAlignment = DALGIN_DETECTOR;
+    this->normalizeFeature = false;
+}
 
-#include "vislearning/features/localfeatures/sift.h"
-
-using namespace OBJREC;
+LFSiftPP::LFSiftPP( const Config * _conf )
+{
+  this->initFromConfig( _conf );
+}
 
+LFSiftPP::~LFSiftPP()
+{
+}
 
-LFSiftPP::LFSiftPP( const Config *conf )
+void LFSiftPP::initFromConfig(const NICE::Config * _conf, const std::string & _confSection)
 {
-    threshold      = conf->gD("LFSiftPP", "threshold", 0.0);
-    edgeThreshold  = conf->gD("LFSiftPP", "edge_threshold", 10.0);
-    octaves        = conf->gI("LFSiftPP", "octaves", 6);
-    first_octave   = conf->gI("LFSiftPP", "first_octave", -1);
-    levels         = conf->gI("LFSiftPP", "levels", 3);
+    this->threshold      = _conf->gD(_confSection, "threshold", 0.0);
+    this->edgeThreshold  = _conf->gD(_confSection, "edge_threshold", 10.0);
+    this->octaves        = _conf->gI(_confSection, "octaves", 6);
+    this->first_octave   = _conf->gI(_confSection, "first_octave", -1);
+    this->levels         = _conf->gI(_confSection, "levels", 3);
     
-    minScale       = conf->gD("LFSiftPP", "min_scale", 1);
-    maxScale       = conf->gD("LFSiftPP", "max_scale", 4);
-    numScales      = conf->gI("LFSiftPP", "num_scales", 10);
-    numAngles      = conf->gI("LFSiftPP", "num_angles", 6 );
+    this->minScale       = _conf->gD(_confSection, "min_scale", 1);
+    this->maxScale       = _conf->gD(_confSection, "max_scale", 4);
+    this->numScales      = _conf->gI(_confSection, "num_scales", 10);
+    this->numAngles      = _conf->gI(_confSection, "num_angles", 6 );
 
-    std::string descriptorAlignment_s = conf->gS("LFSiftPP", "descriptor_alignment", "detector" );
+    std::string descriptorAlignment_s = _conf->gS(_confSection, "descriptor_alignment", "detector" );
 
     if ( descriptorAlignment_s == "detector" )
-		descriptorAlignment = DALGIN_DETECTOR;
+                this->descriptorAlignment = DALGIN_DETECTOR;
     else if ( descriptorAlignment_s == "multiple" )
-		descriptorAlignment = DALIGN_MULTIPLE;
+                this->descriptorAlignment = DALIGN_MULTIPLE;
     else {
-		fprintf (stderr, "LFSiftPP: descriptor alignment method unknown !\n");
-		exit(-1);
+                fprintf (stderr, "LFSiftPP: descriptor alignment method unknown !\n");
+                exit(-1);
     }
 
-    normalizeFeature = conf->gB("LFSiftPP", "normalize_feature", false );
+    this->normalizeFeature = _conf->gB(_confSection, "normalize_feature", false );
 
+    //TODO check whether this os is still needed here.
     std::ostringstream os;
     os << "siftpp_" << "l" << levels << "_o" 
        << octaves << "_m" << minScale << "_t" 
        << threshold << "_e" << edgeThreshold;
 
     if ( ! normalizeFeature )
-		os << "_nd";
+                os << "_nd";  
 }
 
-LFSiftPP::~LFSiftPP()
-{
-}
+///////////////////// ///////////////////// /////////////////////
+//                      FEATURE STUFF
+///////////////////// ///////////////////// /////////////////
 
 int LFSiftPP::getDescSize () const
 {
@@ -245,3 +276,187 @@ void LFSiftPP::visualizeFeatures ( NICE::Image & mark,
 }
 
 
+///////////////////// INTERFACE PERSISTENT /////////////////////
+// interface specific methods for store and restore
+///////////////////// INTERFACE PERSISTENT ///////////////////// 
+
+void LFSiftPP::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, "LFSiftPP" ) )
+    {
+      std::cerr << " WARNING - attempt to restore LFSiftPP, 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, "LFSiftPP" ) )
+      {
+        b_endOfBlock = true;
+        continue;
+      }      
+      
+      tmp = this->removeStartTag ( tmp );   
+
+      
+      if ( tmp.compare("threshold") == 0 )
+      {
+        is >> this->threshold;
+        is >> tmp; // end of block 
+        tmp = this->removeEndTag ( tmp );
+      }
+      else if ( tmp.compare("edgeThreshold") == 0 )
+      {
+        is >> this->edgeThreshold;
+        is >> tmp; // end of block 
+        tmp = this->removeEndTag ( tmp );
+      }      
+      else if ( tmp.compare("octaves") == 0 )
+      {
+        is >> this->octaves;
+        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("levels") == 0 )
+      {
+        is >> this->levels;
+        is >> tmp; // end of block 
+        tmp = this->removeEndTag ( tmp );
+      }
+      else if ( tmp.compare("minScale") == 0 )
+      {
+        is >> this->minScale;
+        is >> tmp; // end of block 
+        tmp = this->removeEndTag ( tmp );
+      }
+      else if ( tmp.compare("maxScale") == 0 )
+      {
+        is >> this->maxScale;
+        is >> tmp; // end of block 
+        tmp = this->removeEndTag ( tmp );
+      }
+      else if ( tmp.compare("numScales") == 0 )
+      {
+        is >> this->numScales;
+        is >> tmp; // end of block 
+        tmp = this->removeEndTag ( tmp );
+      }
+      else if ( tmp.compare("numAngles") == 0 )
+      {
+        is >> this->numAngles;
+        is >> tmp; // end of block 
+        tmp = this->removeEndTag ( tmp );
+      }
+      else if ( tmp.compare("descriptorAlignment") == 0 )
+      {
+        unsigned int ui_descriptorAlignment;        
+        is >> ui_descriptorAlignment;        
+        this->descriptorAlignment = static_cast<DESCRIPTORALIGNMENT> ( ui_descriptorAlignment ) ;
+        
+        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
+      {
+      std::cerr << "WARNING -- unexpected LFSiftPP object -- " << tmp << " -- for restoration... aborting" << std::endl;
+      throw;
+      }
+    }
+  }
+  else
+  {
+    std::cerr << "LFSiftPP::restore -- InStream not initialized - restoring not possible!" << std::endl;
+    throw;
+  }
+}
+
+void LFSiftPP::store ( std::ostream & os, int format ) const
+{ 
+  if (os.good())
+  {
+    // show starting point
+    os << this->createStartTag( "LFSiftPP" ) << std::endl; 
+    
+    os << this->createStartTag( "threshold" ) << std::endl;
+    os << this->threshold << std::endl;
+    os << this->createEndTag( "threshold" ) << std::endl;  
+
+    os << this->createStartTag( "edgeThreshold" ) << std::endl;
+    os << this->edgeThreshold << std::endl;
+    os << this->createEndTag( "edgeThreshold" ) << std::endl;
+    
+    os << this->createStartTag( "octaves" ) << std::endl;
+    os << this->octaves << std::endl;
+    os << this->createEndTag( "octaves" ) << 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( "levels" ) << std::endl;
+    os << this->levels << std::endl;
+    os << this->createEndTag( "levels" ) << std::endl;    
+    
+    os << this->createStartTag( "minScale" ) << std::endl;
+    os << this->minScale << std::endl;
+    os << this->createEndTag( "minScale" ) << std::endl;  
+
+    os << this->createStartTag( "maxScale" ) << std::endl;
+    os << this->maxScale << std::endl;
+    os << this->createEndTag( "maxScale" ) << std::endl;
+    
+    os << this->createStartTag( "numScales" ) << std::endl;
+    os << this->numScales << std::endl;
+    os << this->createEndTag( "numScales" ) << std::endl;  
+
+    os << this->createStartTag( "numAngles" ) << std::endl;
+    os << this->numAngles << std::endl;
+    os << this->createEndTag( "numAngles" ) << std::endl; 
+    
+    os << this->createStartTag( "descriptorAlignment" ) << std::endl;
+    os << this->descriptorAlignment << std::endl;
+    os << this->createEndTag( "descriptorAlignment" ) << std::endl;
+    
+    os << this->createStartTag( "normalizeFeature" ) << std::endl;
+    os << this->normalizeFeature << std::endl;
+    os << this->createEndTag( "normalizeFeature" ) << std::endl; 
+    
+    
+    // done
+    os << this->createEndTag( "LFSiftPP" ) << std::endl;    
+  }
+  else
+  {
+    std::cerr << "OutStream not initialized - storing not possible!" << std::endl;
+  }
+}
+
+void LFSiftPP::clear ()
+{
+}

+ 111 - 40
features/localfeatures/LFSiftPP.h

@@ -1,20 +1,24 @@
 /** 
 * @file LFSiftPP.h
 * @brief Sift++ interface (with detector!)
-* @author Erik Rodner
+* @author Erik Rodner, Alexander Freytag
 * @date 11/19/2007
 
 */
 #ifndef LFSIFTPPINCLUDE
 #define LFSIFTPPINCLUDE
 
-#include "core/imagedisplay/ImageDisplay.h"
+// nice-core includes
+#include <core/basics/Config.h>
+//
+#include <core/image/ImageT.h>
+// 
+#include <core/imagedisplay/ImageDisplay.h>
+// 
+#include <core/vector/VectorT.h>
+#include <core/vector/MatrixT.h>
 
-#include "core/vector/VectorT.h"
-#include "core/vector/MatrixT.h"
-#include "core/image/ImageT.h"
-
-#include "core/basics/Config.h"
+// nice-vislearning includes
 #include "LocalFeatureRepresentation.h"
 
 
@@ -24,42 +28,109 @@ namespace OBJREC {
 class LFSiftPP : public LocalFeatureRepresentation
 {
 
-    protected:
-	enum {
-	    DALGIN_DETECTOR = 0,
-	    DALIGN_MULTIPLE
-	};
-
-	int descriptorAlignment;
-	double minScale;
-	double maxScale;
-	int numScales;
-	int numAngles;
-
-	float threshold;
-	float edgeThreshold;
-	int levels;
-	int octaves;
-	int first_octave;
-	bool normalizeFeature;
-
-    public:
+  protected:
+      
+    /////////////////////////
+    /////////////////////////
+    // PROTECTED VARIABLES //
+    /////////////////////////
+    /////////////////////////         
+      enum DESCRIPTORALIGNMENT{
+          DALGIN_DETECTOR = 0,
+          DALIGN_MULTIPLE
+      };
+
+      DESCRIPTORALIGNMENT descriptorAlignment;
+      
+      double minScale;
+      
+      double maxScale;
+      
+      int numScales;
+      
+      int numAngles;
+
+      
+      float threshold;
+      
+      float edgeThreshold;
+      
+      int levels;
+      
+      int octaves;
+      
+      int first_octave;
+      
+      bool normalizeFeature;
+
+  public:
+    
+    ///////////////////// ///////////////////// /////////////////////
+    //                   CONSTRUCTORS / DESTRUCTORS
+    ///////////////////// ///////////////////// /////////////////////
+    
+    /** 
+     * @brief default constructor
+     * @date 10-02-2014 (dd-mm-yyyy )
+     * @author Alexander Freytag
+     */
+    LFSiftPP ( );     
+
+    /** 
+     * @brief simple constructor 
+     */
+    LFSiftPP( const NICE::Config *conf );
   
-	/** simple constructor */
-	LFSiftPP( const NICE::Config *conf );
+    /** 
+     * @brief simple destructor 
+     */
+    virtual ~LFSiftPP();
+      
+    /** 
+     * @brief Jobs previously performed in the config-version of the constructor, read settings etc.
+     * @author Alexander Freytag
+     * @date 10-02-2014 ( dd-mm-yyyy )
+     */    
+    void initFromConfig ( const NICE::Config * _conf, const std::string & _confSection = "LFSiftPP");       
       
-	/** simple destructor */
-	virtual ~LFSiftPP();
-	
-	int getDescSize () const;
-
-	int extractFeatures ( const NICE::Image & img, NICE::VVector & features, 
-			      NICE::VVector & positions ) const;
- 
-	void visualizeFeatures ( NICE::Image & mark,
-				 const NICE::VVector & positions,
-				 size_t color ) const;
+    ///////////////////// ///////////////////// /////////////////////
+    //                      FEATURE STUFF
+    ///////////////////// ///////////////////// //////////////////       
+      
+    int getDescSize () const;
+
+    int extractFeatures ( const NICE::Image & img, NICE::VVector & features, 
+                          NICE::VVector & positions ) const;
+
+    void visualizeFeatures ( NICE::Image & mark,
+                              const NICE::VVector & positions,
+                              size_t color ) const;
+                                
+    ///////////////////// INTERFACE PERSISTENT /////////////////////
+    // interface specific methods for store and restore
+    ///////////////////// INTERFACE PERSISTENT /////////////////////   
     
+    /** 
+     * @brief Load object from external file (stream)
+     * @author Alexander Freytag
+     * @date 09-02-2014 ( dd-mmyyyy)
+     */     
+    virtual void restore ( std::istream & is, int format = 0 );
+    
+    /** 
+     * @brief Save object to external file (stream)
+     * @author Alexander Freytag
+     * @date 09-02-2014 ( dd-mmyyyy)
+     */       
+    virtual void store( std::ostream & os, int format = 0 ) const;
+    
+    /** 
+     * @brief Clear  object
+     * @author Alexander Freytag
+     * @date 09-02-2014 ( dd-mmyyyy)
+     */    
+    virtual void clear ();                                 
+  
 };
 
 

+ 2 - 2
features/localfeatures/LocalFeatureRGBSift.cpp

@@ -36,8 +36,8 @@ void LocalFeatureRGBSift::initFromConfig( const NICE::Config* _conf, const std::
   //first of all, call method of parent object
   LocalFeatureSift::initFromConfig( _conf );
   
-  //set deletemode variable of partent object
-  this->deletemode = false;  
+  //set deletemode variable of parent object
+  this->deletemode = false;
 }
 
 ///////////////////// ///////////////////// /////////////////////

+ 61 - 27
features/localfeatures/LocalFeatureRepresentation.h

@@ -13,6 +13,7 @@
 
 // nice-core includes
 #include <core/basics/Exception.h>
+#include <core/basics/Persistent.h>
 // 
 #include <core/image/ImageT.h>
 #include <core/imagedisplay/ImageDisplay.h>
@@ -31,35 +32,68 @@ namespace OBJREC {
  * @brief Absract class for Local Feature Representations (Detector + Descriptor)
  *
  */
-class LocalFeatureRepresentation
+class LocalFeatureRepresentation : public NICE::Persistent
 {
 
-    protected:
-
-    public:
-  
-	/** simple constructor */
-	LocalFeatureRepresentation();
-      
-	/** simple destructor */
-	virtual ~LocalFeatureRepresentation();
-
-	virtual int getDescSize () const = 0;
-
-	virtual int extractFeatures ( const NICE::Image & img, 
-				      NICE::VVector & features, 
-				      NICE::VVector & positions ) const = 0;
-	
-	virtual int extractFeatures ( const NICE::ColorImage & img, 
-				      NICE::VVector & features, 
-				      NICE::VVector & positions ) const;
-
-	virtual void visualizeFeatures ( NICE::Image & mark,
-					 const NICE::VVector & positions,
-					 size_t color ) const;
-
-	virtual void visualize ( NICE::Image & img, 
-				 const NICE::Vector & feature ) const;
+  protected:
+
+  public:
+    
+    ///////////////////// ///////////////////// /////////////////////
+    //                   CONSTRUCTORS / DESTRUCTORS
+    ///////////////////// ///////////////////// /////////////////////         
+
+    /** simple constructor */
+    LocalFeatureRepresentation();
+    
+    /** simple destructor */
+    virtual ~LocalFeatureRepresentation();
+
+    ///////////////////// ///////////////////// /////////////////////
+    //                      FEATURE STUFF
+    ///////////////////// ///////////////////// //////////////////
+
+    virtual int getDescSize () const = 0;
+
+    virtual int extractFeatures ( const NICE::Image & img,
+                                  NICE::VVector & features,
+                                  NICE::VVector & positions ) const = 0;
+
+    virtual int extractFeatures ( const NICE::ColorImage & img,
+                                  NICE::VVector & features,
+                                  NICE::VVector & positions ) const;
+
+    virtual void visualizeFeatures ( NICE::Image & mark,
+                                    const NICE::VVector & positions,
+                                    size_t color ) const;
+
+    virtual void visualize ( NICE::Image & img,
+                            const NICE::Vector & feature ) const;
+
+    ///////////////////// INTERFACE PERSISTENT /////////////////////
+    // interface specific methods for store and restore
+    ///////////////////// INTERFACE PERSISTENT /////////////////////
+
+    /**
+    * @brief Load object from external file (stream)
+    * @author Alexander Freytag
+    * @date 09-02-2014 ( dd-mm-yyyy )
+    */
+    void restore ( std::istream & is, int format = 0 ) = 0;
+
+    /**
+    * @brief Save object to external file (stream)
+    * @author Alexander Freytag
+    * @date 09-02-2014 ( dd-mm-yyyy )
+    */
+    void store ( std::ostream & os, int format = 0 ) const = 0;
+
+    /**
+    * @brief Clear object
+    * @author Alexander Freytag
+    * @date 09-02-2014 ( dd-mm-yyyy )
+    */
+    void clear () = 0;  
 
 };