|
@@ -38,7 +38,7 @@ class GenericLocalFeatureSelection
|
|
|
* @param[in] string - This string defines the value for "section" in the configfile.
|
|
|
* @return LocalFeature* - The LocalFeature which contains the selected LocalFeature-Type.
|
|
|
*/
|
|
|
- static LocalFeature *selectLocalFeature ( const NICE::Config *conf, std::string section = "Features" )
|
|
|
+ static OBJREC::LocalFeature *selectLocalFeature ( const NICE::Config *conf, std::string section = "Features" )
|
|
|
{
|
|
|
// return Value
|
|
|
LocalFeature *lf = NULL;
|
|
@@ -48,23 +48,23 @@ class GenericLocalFeatureSelection
|
|
|
|
|
|
// The prefix NICE_* indicates that this implementation comes from a NICE-Developer.
|
|
|
// Extern implementations can be added without NICE_* in this selection-class.
|
|
|
- if ( localfeature_type == "NICE_SIFT" )
|
|
|
+ if ( ( localfeature_type == "NICE_SIFT" ) || ( localfeature_type == "LocalFeatureSift" ) )
|
|
|
{
|
|
|
lf = new OBJREC::LocalFeatureSift ( conf );
|
|
|
}
|
|
|
- else if ( localfeature_type == "NICE_RGBSIFT" )
|
|
|
+ else if ( ( localfeature_type == "NICE_RGBSIFT" ) || ( localfeature_type == "LocalFeatureRGBSift" ) )
|
|
|
{
|
|
|
lf = new OBJREC::LocalFeatureRGBSift ( conf );
|
|
|
}
|
|
|
- else if ( localfeature_type == "NICE_OPPSIFT" )
|
|
|
+ else if ( ( localfeature_type == "NICE_OPPSIFT" ) || ( localfeature_type == "LocalFeatureOpponnentSift" ) )
|
|
|
{
|
|
|
lf = new OBJREC::LocalFeatureOpponnentSift ( conf );
|
|
|
}
|
|
|
- else if ( localfeature_type == "colornames" )
|
|
|
+ else if ( ( localfeature_type == "colornames" ) || ( localfeature_type == "LocalFeatureColorWeijer" ) )
|
|
|
{
|
|
|
lf = new OBJREC::LocalFeatureColorWeijer ( conf );
|
|
|
}
|
|
|
- else if ( localfeature_type == "centrist" )
|
|
|
+ else if ( ( localfeature_type == "centrist" ) || ( localfeature_type == "LocalFeatureCentrist" ) )
|
|
|
{
|
|
|
lf = new OBJREC::LocalFeatureCentrist ( conf );
|
|
|
}
|
|
@@ -72,10 +72,67 @@ class GenericLocalFeatureSelection
|
|
|
|
|
|
// no correct localfeature_type was given
|
|
|
if ( lf == NULL )
|
|
|
- fthrow ( NICE::Exception, "Local feature type not found: " << localfeature_type );
|
|
|
+ fthrow ( NICE::Exception, "Local feature type not found: " << localfeature_type << " for section " << section);
|
|
|
|
|
|
return lf;
|
|
|
- }
|
|
|
+ };
|
|
|
+
|
|
|
+ static
|
|
|
+ void restoreLocalFeature ( OBJREC::LocalFeature * _lf, std::istream & is, int format = 0 )
|
|
|
+ {
|
|
|
+
|
|
|
+ if ( is.good() )
|
|
|
+ {
|
|
|
+ if ( _lf != NULL )
|
|
|
+ delete _lf;
|
|
|
+
|
|
|
+
|
|
|
+ std::string className;
|
|
|
+ is >> className; //class name
|
|
|
+
|
|
|
+
|
|
|
+ if ( className == "<LocalFeatureSift>" )
|
|
|
+ {
|
|
|
+ _lf = new OBJREC::LocalFeatureSift();
|
|
|
+ }
|
|
|
+ else if ( className == "<LocalFeatureRGBSift>" )
|
|
|
+ {
|
|
|
+ _lf = new OBJREC::LocalFeatureRGBSift();
|
|
|
+ }
|
|
|
+ else if ( className == "<LocalFeatureOpponnentSift>" )
|
|
|
+ {
|
|
|
+ _lf = new OBJREC::LocalFeatureOpponnentSift();
|
|
|
+ }
|
|
|
+ else if ( className == "<LocalFeatureColorWeijer>" )
|
|
|
+ {
|
|
|
+ _lf = new OBJREC::LocalFeatureColorWeijer();
|
|
|
+ }
|
|
|
+ else if ( className == "<LocalFeatureCentrist>" )
|
|
|
+ {
|
|
|
+ _lf = new OBJREC::LocalFeatureCentrist();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ fthrow ( NICE::Exception, "GenericLocalFeatureSelection::restoreLocalFeatureRep -- class name " << className << "unknown. Aborting." );
|
|
|
+ }
|
|
|
+
|
|
|
+ //undo reading of class name
|
|
|
+
|
|
|
+ for ( uint i = 0; i < className.size(); i++)
|
|
|
+ {
|
|
|
+ is.unget();
|
|
|
+ }
|
|
|
+
|
|
|
+ //now, call the restore method of the underlying object
|
|
|
+ //NOTE this could be also done externally, leaving only the actual instantiation of the derived objects here
|
|
|
+ _lf->restore ( is );
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ fthrow ( NICE::Exception, "GenericLocalFeatureSelection::restoreLocalFeatureRep -- InStream not initialized - restoring not possible!" );
|
|
|
+ }
|
|
|
+ };
|
|
|
};
|
|
|
}
|
|
|
|