瀏覽代碼

bugfixes in LFonHSG persistent methods

Alexander Freytag 11 年之前
父節點
當前提交
088ad8ee55

+ 9 - 5
features/localfeatures/LFonHSG.cpp

@@ -100,7 +100,7 @@ void OBJREC::LFonHSG::initFromConfig(const NICE::Config * _conf, const std::stri
   this->scales        = _conf->gS (_confSection, "scales"        , "1");
   this->scales        = _conf->gS (_confSection, "scales"        , "1");
   
   
   this->lf            = NULL;
   this->lf            = NULL;
-  this->lf            = GenericLocalFeatureSelection::selectLocalFeature (_conf, _confSection /*TODO check whether it is useful to hand over the confSection string here*/);
+  this->lf            = OBJREC::GenericLocalFeatureSelection::selectLocalFeature (_conf, _confSection /*TODO check whether it is useful to hand over the confSection string here*/);
 
 
   /** parse scales string **/
   /** parse scales string **/
   this->convertScalesStringToScaleList();
   this->convertScalesStringToScaleList();
@@ -195,7 +195,7 @@ void LFonHSG::restore ( std::istream & is, int format )
     
     
     std::string tmp;
     std::string tmp;
     is >> tmp; //class name 
     is >> tmp; //class name 
-    
+        
     if ( ! this->isStartTag( tmp, "LFonHSG" ) )
     if ( ! this->isStartTag( tmp, "LFonHSG" ) )
     {
     {
       std::cerr << " WARNING - attempt to restore LFonHSG, but start flag " << tmp << " does not match! Aborting... " << std::endl;
       std::cerr << " WARNING - attempt to restore LFonHSG, but start flag " << tmp << " does not match! Aborting... " << std::endl;
@@ -215,7 +215,6 @@ void LFonHSG::restore ( std::istream & is, int format )
       }      
       }      
       
       
       tmp = this->removeStartTag ( tmp );   
       tmp = this->removeStartTag ( tmp );   
-
       
       
       if ( tmp.compare("debug") == 0 )
       if ( tmp.compare("debug") == 0 )
       {
       {
@@ -237,6 +236,7 @@ void LFonHSG::restore ( std::istream & is, int format )
       }
       }
       else if ( tmp.compare("scalesV") == 0 )
       else if ( tmp.compare("scalesV") == 0 )
       {
       {
+        is >> tmp; //size:
         unsigned int ui_scalesVSize;
         unsigned int ui_scalesVSize;
         is >> ui_scalesVSize;
         is >> ui_scalesVSize;
         this->scalesV.clear();
         this->scalesV.clear();
@@ -254,7 +254,7 @@ void LFonHSG::restore ( std::istream & is, int format )
       } 
       } 
       else if ( tmp.compare("lf") == 0 )
       else if ( tmp.compare("lf") == 0 )
       {
       {
-        this->lf->restore ( is );
+        OBJREC::GenericLocalFeatureSelection::restoreLocalFeature( this->lf, is );
         is >> tmp; // end of block 
         is >> tmp; // end of block 
         tmp = this->removeEndTag ( tmp );
         tmp = this->removeEndTag ( tmp );
       }    
       }    
@@ -300,7 +300,11 @@ void LFonHSG::store ( std::ostream & os, int format ) const
     os << this->createEndTag( "scalesV" ) << std::endl;  
     os << this->createEndTag( "scalesV" ) << std::endl;  
 
 
     os << this->createStartTag( "lf" ) << std::endl;
     os << this->createStartTag( "lf" ) << std::endl;
-    this->lf->store ( os );
+    if ( this->lf != NULL )
+    {
+      //TODO this might be tricky if lf was not intantiated properly.      
+      this->lf->store ( os );
+    }
     os << this->createEndTag( "lf" ) << std::endl; 
     os << this->createEndTag( "lf" ) << std::endl; 
     
     
     // done
     // done

+ 2 - 2
features/localfeatures/tests/TestGenericLFSelectionPersistent.cpp

@@ -45,7 +45,7 @@ void TestGenericLFSelectionPersistent::testPersistentMethods()
   if ( verbose )
   if ( verbose )
     std::cerr << " TEST STORING ABILITIES " << std::endl;
     std::cerr << " TEST STORING ABILITIES " << std::endl;
   
   
-  std::string s_destination_save ( "myLocalFeatureSelection.txt" );
+  std::string s_destination_save ( "myLFSelection.txt" );
   
   
   std::filebuf fbOut;
   std::filebuf fbOut;
   fbOut.open ( s_destination_save.c_str(), ios::out );
   fbOut.open ( s_destination_save.c_str(), ios::out );
@@ -61,7 +61,7 @@ void TestGenericLFSelectionPersistent::testPersistentMethods()
     
     
   OBJREC::LocalFeatureRepresentation * lfrepRestore = NULL;  
   OBJREC::LocalFeatureRepresentation * lfrepRestore = NULL;  
       
       
-  std::string s_destination_load ( "myLocalFeatureSelection.txt" );
+  std::string s_destination_load ( "myLFSelection.txt" );
   
   
   std::filebuf fbIn;
   std::filebuf fbIn;
   fbIn.open ( s_destination_load.c_str(), ios::in );
   fbIn.open ( s_destination_load.c_str(), ios::in );