浏览代码

Merge branch 'master' of /home/dbv/git/nice/vislearning

Erik Rodner 13 年之前
父节点
当前提交
4fc0d3d4b8

+ 16 - 16
baselib/Globals.h

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file Globals.h
 * @brief some routines which provide access to global variables
 * @author Erik Rodner
@@ -14,22 +14,22 @@ namespace OBJREC {
 
 /** @brief some routines which provide access to global variables */
 class Globals {
-    
-    private:
+
+  private:
 
     /** image filename which is currently processed */
     static std::string currentImgFN;
 
-    public:
+  public:
 
-	/** cache mode: none "none" (<root>/<imgfn>), categories "cat" (<root>/<last-dir-part>/<imgfn>),
-	    categories_secondpart "cat2" (<root>/<second-last-dir-part>/<imgfn>) */
+    /** cache mode: none "none" (<root>/<imgfn>), categories "cat" (<root>/<last-dir-part>/<imgfn>),
+        categories_secondpart "cat2" (<root>/<second-last-dir-part>/<imgfn>) */
     enum {
-		SORT_NONE = 0,
-		SORT_CATEGORIES,
-		SORT_CATEGORIES_SECONDPART
+      SORT_NONE = 0,
+      SORT_CATEGORIES,
+      SORT_CATEGORIES_SECONDPART
     };
-   
+
     /** set filename of the image which is currently processed */
     static void setCurrentImgFN ( const std::string & imgfn );
 
@@ -37,15 +37,15 @@ class Globals {
     static std::string getCurrentImgFN ();
 
     /** get a filename which can be used for caching
-	@param root root directory of the global cache
-	@param cache_mode mode of the caching
-	@return cache filename
+    @param root root directory of the global cache
+    @param cache_mode mode of the caching
+    @return cache filename
     */
     static std::string getCacheFilename ( const std::string & root, int cache_mode );
-    
+
     /** get cache mode
-	@param desc description of the cache
-	@return determined cache mode
+    @param desc description of the cache
+    @return determined cache mode
     */
     static int getCacheMode ( const std::string & desc );
 

+ 340 - 338
cbaselib/ClassNames.cpp

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file ClassNames.cpp
 * @brief simple interface for class name confusion
 * @author Erik Rodner
@@ -27,454 +27,456 @@ using namespace NICE;
 
 ClassNames::ClassNames()
 {
-	maxClassNo = 0;
+  maxClassNo = 0;
 }
 
-ClassNames::ClassNames ( const ClassNames & cn, 
-			 const std::string & classselection )
+ClassNames::ClassNames ( const ClassNames & cn,
+                         const std::string & classselection )
 {
-	std::set<int> selection;
-	cn.getSelection ( classselection, selection );
-	maxClassNo = 0;
-
-	store ( cerr );
-
-	for ( map<string, string>::const_iterator i  = cn.tbl_code_text.begin();
-						  i != cn.tbl_code_text.end();
-						  i++ )
-	{
-		const std::string & classname = i->second;
-		std::string code = i->first;
-
-		if ( cn.tbl_code_classno.find(code) == cn.tbl_code_classno.end() )
-		{
-			fprintf (stderr, "class %s excluded in base classnames\n", code.c_str() );
-			continue;
-		}
-
-		int classno = cn.classno(code);
-		if ( selection.find(classno) != selection.end() )
-		{
-			addClass( classno, code, classname );
-			if ( classno > maxClassNo ) maxClassNo = classno;
+  std::set<int> selection;
+  cn.getSelection ( classselection, selection );
+  maxClassNo = 0;
+
+  store ( cerr );
+
+  for ( map<string, string>::const_iterator i  = cn.tbl_code_text.begin();
+        i != cn.tbl_code_text.end();
+        i++ )
+  {
+    const std::string & classname = i->second;
+    std::string code = i->first;
+
+    if ( cn.tbl_code_classno.find ( code ) == cn.tbl_code_classno.end() )
+    {
+      fprintf ( stderr, "class %s excluded in base classnames\n", code.c_str() );
+      continue;
+    }
+
+    int classno = cn.classno ( code );
+    if ( selection.find ( classno ) != selection.end() )
+    {
+      addClass ( classno, code, classname );
+      if ( classno > maxClassNo ) maxClassNo = classno;
 #ifdef DEBUG_ClassNames
-			fprintf (stderr, "class %s (%d) inherited\n", code.c_str(), classno );
+      fprintf ( stderr, "class %s (%d) inherited\n", code.c_str(), classno );
 #endif
-		} else {
+    } else {
 #ifdef DEBUG_ClassNames
-			fprintf (stderr, "class %s (%d) excluded in selection\n", code.c_str(), classno );
+      fprintf ( stderr, "class %s (%d) excluded in selection\n", code.c_str(), classno );
 #endif
-		}
-	}
+    }
+  }
 }
 
 ClassNames::ClassNames ( const ClassNames & cn )
-	: tbl_code_text(cn.tbl_code_text), tbl_text_code(cn.tbl_text_code),
-	  tbl_classno_code(cn.tbl_classno_code), tbl_code_classno(cn.tbl_code_classno),
-	  tbl_color_classno(tbl_color_classno), tbl_classno_color(cn.tbl_classno_color), maxClassNo(cn.maxClassNo)
+    : tbl_code_text ( cn.tbl_code_text ), tbl_text_code ( cn.tbl_text_code ),
+    tbl_classno_code ( cn.tbl_classno_code ), tbl_code_classno ( cn.tbl_code_classno ),
+    tbl_color_classno ( tbl_color_classno ), tbl_classno_color ( cn.tbl_classno_color ), maxClassNo ( cn.maxClassNo )
 {
 }
 
 ClassNames::~ClassNames()
 {
 }
-	
+
 
 int ClassNames::classnoFromText ( std::string text ) const
 {
-	map<string, string>::const_iterator j = tbl_text_code.find(text);
-	if ( j == tbl_text_code.end() ) return -1;
+  map<string, string>::const_iterator j = tbl_text_code.find ( text );
+  if ( j == tbl_text_code.end() ) return -1;
 
-	map<string, int>::const_iterator jj = tbl_code_classno.find(j->second);
-	if ( jj == tbl_code_classno.end() ) return -1;
+  map<string, int>::const_iterator jj = tbl_code_classno.find ( j->second );
+  if ( jj == tbl_code_classno.end() ) return -1;
 
-	return jj->second;
+  return jj->second;
 }
 
 void ClassNames::getSelection ( const std::string & classselection,
-				std::set<int> & classnos ) const
+                                std::set<int> & classnos ) const
 {
-	if ( classselection.size() <= 0 ) return;
-
-	std::vector<string> classlist;
-	StringTools::split ( classselection, ',', classlist );
-
-	if ( classlist.size() <= 0 )
-	{
-	fprintf (stderr, "FATAL ERROR: wrong format for classselection\n");
-	exit(-1);
-	} else if ( classlist[0] == "*" )
-	{
-	map<string, bool> forbidden_classes;
-	for ( size_t k = 1 ; k < classlist.size() ; k++ )
-		if ( classlist[k].substr(0,1) == "-" )
-		{
-			std::string f_class = classlist[k].substr(1);
+  if ( classselection.size() <= 0 ) return;
+
+  std::vector<string> classlist;
+  StringTools::split ( classselection, ',', classlist );
+
+  if ( classlist.size() <= 0 )
+  {
+    fprintf ( stderr, "FATAL ERROR: wrong format for classselection\n" );
+    exit ( -1 );
+  } else if ( classlist[0] == "*" )
+  {
+    map<string, bool> forbidden_classes;
+    for ( size_t k = 1 ; k < classlist.size() ; k++ )
+      if ( classlist[k].substr ( 0, 1 ) == "-" )
+      {
+        std::string f_class = classlist[k].substr ( 1 );
 #if defined DEBUG_ClassNames
-			fprintf (stderr, "ClassNames: class %s excluded !\n", f_class.c_str() );
+        fprintf ( stderr, "ClassNames: class %s excluded !\n", f_class.c_str() );
 #endif
-			forbidden_classes[ f_class ] = true;
-		} else {
-			fprintf (stderr, "FATAL ERROR: wrong format for classselection: *,-class0,class1,...\n");
-			exit(-1);
-		}
-   
-	for ( map<int, string>::const_iterator i  = tbl_classno_code.begin();
-						  i != tbl_classno_code.end();
-						  i++ )
-	{
-		int myclassno = i->first;
-		const std::string & classname = text(myclassno);
-		if ( forbidden_classes.find(classname) != forbidden_classes.end() )
-		continue;
-		
-		classnos.insert ( myclassno );
-	}
-	} else {
-		for ( vector<string>::const_iterator i  = classlist.begin();
-							i != classlist.end();
-							i++ )
-		{
-			const std::string & classname = *i;
-			map<string, string>::const_iterator j = tbl_text_code.find(classname);
-	
-			if ( j == tbl_text_code.end() )
-			{
-				fprintf (stderr, "ClassNames: FATAL ERROR This is not a selection of a subset: %s [%s]\n",
-					classname.c_str(), classselection.c_str());
-				exit(-1);
-			}
-	
-			const std::string & code = j->second;
-			int myclassno = classno (code);
-	
-			if ( myclassno < 0 ) {
-				fprintf (stderr, "ClassNames: FATAL ERROR This is not a selection of a subset\n");
-				exit(-1);
-			}
-			classnos.insert ( myclassno );
-		}
-	}
+        forbidden_classes[ f_class ] = true;
+      } else {
+        fprintf ( stderr, "FATAL ERROR: wrong format for classselection: *,-class0,class1,...\n" );
+        exit ( -1 );
+      }
+
+    for ( map<int, string>::const_iterator i  = tbl_classno_code.begin();
+          i != tbl_classno_code.end();
+          i++ )
+    {
+      int myclassno = i->first;
+      const std::string & classname = text ( myclassno );
+      if ( forbidden_classes.find ( classname ) != forbidden_classes.end() )
+        continue;
+
+      classnos.insert ( myclassno );
+    }
+  } else {
+    for ( vector<string>::const_iterator i  = classlist.begin();
+          i != classlist.end();
+          i++ )
+    {
+      const std::string & classname = *i;
+      map<string, string>::const_iterator j = tbl_text_code.find ( classname );
+
+      if ( j == tbl_text_code.end() )
+      {
+        fprintf ( stderr, "ClassNames: FATAL ERROR This is not a selection of a subset: %s [%s]\n",
+                  classname.c_str(), classselection.c_str() );
+        exit ( -1 );
+      }
+
+      const std::string & code = j->second;
+      int myclassno = classno ( code );
+
+      if ( myclassno < 0 ) {
+        fprintf ( stderr, "ClassNames: FATAL ERROR This is not a selection of a subset\n" );
+        exit ( -1 );
+      }
+      classnos.insert ( myclassno );
+    }
+  }
 
 }
 
 std::string ClassNames::text ( int classno ) const
-{  
-	map<string, string>::const_iterator i = 
-		tbl_code_text.find ( code(classno) );
-
-	if ( i == tbl_code_text.end() )
-	{
-		fprintf (stderr, "ClassNames: no name found for classno %d\n", classno );
-		return "unknown";
-	} else {
-		return i->second;
-	}
+{
+  map<string, string>::const_iterator i =
+    tbl_code_text.find ( code ( classno ) );
+
+  if ( i == tbl_code_text.end() )
+  {
+    fprintf ( stderr, "ClassNames: no name found for classno %d\n", classno );
+    return "unknown";
+  } else {
+    return i->second;
+  }
 
 }
 
 std::string ClassNames::code ( int classno ) const
 {
-	map<int, string>::const_iterator i = 
-		tbl_classno_code.find ( classno );
+  map<int, string>::const_iterator i =
+    tbl_classno_code.find ( classno );
 
-	if ( i == tbl_classno_code.end() )
-	{
-		fprintf (stderr, "ClassNames: no code found for classno %d\n", classno );
-		return "unknown";
-	} else {
-		return i->second;
-	}
+  if ( i == tbl_classno_code.end() )
+  {
+    fprintf ( stderr, "ClassNames: no code found for classno %d\n", classno );
+    return "unknown";
+  } else {
+    return i->second;
+  }
 
 }
 
 int ClassNames::classno ( std::string code ) const
 {
-	map<string, int>::const_iterator i = 
-		tbl_code_classno.find ( code );
-
-	if ( i == tbl_code_classno.end() )
-	{
-		fthrow(Exception, "no classno found for code <" << code << ">" );
-	} else {
-		return i->second;
-	}
+  map<string, int>::const_iterator i =
+    tbl_code_classno.find ( code );
+
+  if ( i == tbl_code_classno.end() )
+  {
+    fthrow ( Exception, "no classno found for code <" << code << ">" );
+  } else {
+    return i->second;
+  }
 }
 
 int ClassNames::numClasses () const
 {
-	return tbl_classno_code.size();
+  return tbl_classno_code.size();
 }
 
 
-void ClassNames::addClass ( int classno, const std::string & code, 
-	const std::string & text )
+void ClassNames::addClass ( int classno, const std::string & code,
+                            const std::string & text )
 {
-	tbl_classno_code[classno] = code;
-	tbl_text_code[text]	   = code;
-	tbl_code_text[code]	   = text;
-	tbl_code_classno[code]	= classno;
+  tbl_classno_code[classno] = code;
+  tbl_text_code[text]    = code;
+  tbl_code_text[code]    = text;
+  tbl_code_classno[code] = classno;
 
-	if ( classno > maxClassNo ) maxClassNo = classno;
+  if ( classno > maxClassNo ) maxClassNo = classno;
 }
-	
+
 bool ClassNames::existsClassno ( int classno ) const
 {
-	return (tbl_classno_code.find(classno) != tbl_classno_code.end());
+  return ( tbl_classno_code.find ( classno ) != tbl_classno_code.end() );
 }
 
 // refactor-nice.pl: check this substitution
 // old: bool ClassNames::existsClassCode ( const string & classcode ) const
 bool ClassNames::existsClassCode ( const std::string & classcode ) const
 {
-	return (tbl_code_classno.find(classcode) != tbl_code_classno.end());
+  return ( tbl_code_classno.find ( classcode ) != tbl_code_classno.end() );
 }
 
-bool ClassNames::readFromConfig ( const Config & datasetconf, 
-			// refactor-nice.pl: check this substitution
-			// old: const string & classselection )
-			const std::string & classselection )
+bool ClassNames::readFromConfig ( const Config & datasetconf,
+                                  // refactor-nice.pl: check this substitution
+                                  // old: const string & classselection )
+                                  const std::string & classselection )
 {
 
-	datasetconf.getAllS ( "classnames", tbl_code_text );
+  datasetconf.getAllS ( "classnames", tbl_code_text );
 
-	if ( tbl_code_text.size() <= 0 ) {
-		fprintf (stderr, "ClassNames: no classnames specified\n");
-		return false;
-	}
+  if ( tbl_code_text.size() <= 0 ) {
+    fprintf ( stderr, "ClassNames: no classnames specified\n" );
+    return false;
+  }
 
-	// reverse map and lower case
-	for ( map<string, string>::const_iterator i  = tbl_code_text.begin();
-									   i != tbl_code_text.end(); i++ )
-		tbl_text_code [ i->second ] = i->first;	
+  // reverse map and lower case
+  for ( map<string, string>::const_iterator i  = tbl_code_text.begin();
+        i != tbl_code_text.end(); i++ )
+    tbl_text_code [ i->second ] = i->first;
 
 #if defined DEBUG_ClassNames
-	cerr << "ClassNames::read: selection = " << classselection << endl;
+  cerr << "ClassNames::read: selection = " << classselection << endl;
 #endif
 
-	std::vector<string> classlist;
-	StringTools::split ( classselection, ',', classlist );
-
-	if ( classlist.size() <= 0 )
-	{
-	fprintf (stderr, "FATAL ERROR: wrong format for classselection\n");
-	exit(-1);
-	} else if ( classlist[0] == "*" )
-	{
-	map<string, bool> forbidden_classes;
-	for ( size_t k = 1 ; k < classlist.size() ; k++ )
-		if ( classlist[k].substr(0,1) == "-" )
-		{
-		// refactor-nice.pl: check this substitution
-		// old: string f_class = classlist[k].substr(1);
-		std::string f_class = classlist[k].substr(1);
+  std::vector<string> classlist;
+  StringTools::split ( classselection, ',', classlist );
+
+  if ( classlist.size() <= 0 )
+  {
+    fprintf ( stderr, "FATAL ERROR: wrong format for classselection\n" );
+    exit ( -1 );
+  } else if ( classlist[0] == "*" )
+  {
+    map<string, bool> forbidden_classes;
+    for ( size_t k = 1 ; k < classlist.size() ; k++ )
+      if ( classlist[k].substr ( 0, 1 ) == "-" )
+      {
+        // refactor-nice.pl: check this substitution
+        // old: string f_class = classlist[k].substr(1);
+        std::string f_class = classlist[k].substr ( 1 );
 #if defined DEBUG_ClassNames
-		fprintf (stderr, "ClassNames: class %s excluded !\n", f_class.c_str() );
+        fprintf ( stderr, "ClassNames: class %s excluded !\n", f_class.c_str() );
 #endif
-		forbidden_classes[ f_class ] = true;
-		} else {
-		fprintf (stderr, "FATAL ERROR: wrong format for classselection: *,-class0,class1,...\n");
-		exit(-1);
-		}
-
-	int classno_seq = 0;
-	for ( map<string, string>::const_iterator i  = tbl_code_text.begin();
-						  i != tbl_code_text.end();
-						  i++,classno_seq++ )
-	{
-		const std::string & classname = i->second;
-		if ( forbidden_classes.find(classname) != forbidden_classes.end() )
-			continue;
-
-		// refactor-nice.pl: check this substitution
-		// old: string code = tbl_text_code [ i->second ];
-		std::string code = tbl_text_code [ i->second ];
-		int classno;
-		classno = classno_seq;
-		tbl_classno_code[classno] = code;
-		tbl_code_classno[code] = classno;
-		if ( classno > maxClassNo ) maxClassNo = classno;
+        forbidden_classes[ f_class ] = true;
+      } else {
+        fprintf ( stderr, "FATAL ERROR: wrong format for classselection: *,-class0,class1,...\n" );
+        exit ( -1 );
+      }
+
+    int classno_seq = 0;
+    for ( map<string, string>::const_iterator i  = tbl_code_text.begin();
+          i != tbl_code_text.end();
+          i++, classno_seq++ )
+    {
+      const std::string & classname = i->second;
+      if ( forbidden_classes.find ( classname ) != forbidden_classes.end() )
+        continue;
+
+      // refactor-nice.pl: check this substitution
+      // old: string code = tbl_text_code [ i->second ];
+      std::string code = tbl_text_code [ i->second ];
+      int classno;
+      classno = classno_seq;
+      tbl_classno_code[classno] = code;
+      tbl_code_classno[code] = classno;
+      if ( classno > maxClassNo ) maxClassNo = classno;
 
 #if defined DEBUG_ClassNames
-		fprintf (stderr, "classno %d class code %s class text %s\n", classno, code.c_str(), classname.c_str() );
+      fprintf ( stderr, "classno %d class code %s class text %s\n", classno, code.c_str(), classname.c_str() );
 #endif
-	}
-	} else {
+    }
+  } else {
 
 #if defined DEBUG_ClassNames
-	cerr << "list : " << classlist.size() << endl;
+    cerr << "list : " << classlist.size() << endl;
 #endif
-	for ( size_t classno_seq = 0 ; classno_seq < classlist.size() ; classno_seq++ )
-	{
-		std::string classname = classlist[classno_seq];
-
-		if ( tbl_text_code.find ( classname ) != tbl_text_code.end() )
-		{
-			std::string code = tbl_text_code [ classname ];
-			int classno;
-			classno = classno_seq;
-			tbl_classno_code[classno] = code;
-			tbl_code_classno[code] = classno;
-			if ( classno > maxClassNo ) maxClassNo = classno;
+    for ( size_t classno_seq = 0 ; classno_seq < classlist.size() ; classno_seq++ )
+    {
+      std::string classname = classlist[classno_seq];
+
+      if ( tbl_text_code.find ( classname ) != tbl_text_code.end() )
+      {
+        std::string code = tbl_text_code [ classname ];
+        int classno;
+        classno = classno_seq;
+        tbl_classno_code[classno] = code;
+        tbl_code_classno[code] = classno;
+        if ( classno > maxClassNo ) maxClassNo = classno;
 
 #if defined DEBUG_ClassNames
-			fprintf (stderr, "classno %d class code %s class text %s\n", (int)classno, code.c_str(), classname.c_str() );
+        fprintf ( stderr, "classno %d class code %s class text %s\n", ( int ) classno, code.c_str(), classname.c_str() );
 #endif
-		} else {
-			fprintf (stderr, "ClassNames::ClassNames: FATAL ERROR class >%s< not found in data set\n", classname.c_str() );
-			exit(-1);
-		}
-	}
-	}
-
-	/****** after all, try to read color coding *******/
-	map<string, string> list;
-	datasetconf.getAllS ( "colors", list );
-
-	if ( list.size() > 0 ) {
-		for ( map<string,string>::const_iterator i = list.begin();
-			i != list.end();
-			i++ )
-		{
-			std::string value = i->second;
-			std::string classname = i->first;
-			int _classno = classno(classname);
-			vector<string> submatches;
-			if ( StringTools::regexMatch ( value, "^ *([[:digit:]]+) *: *([[:digit:]]+) *: *([[:digit:]]+) *$", submatches ) 
-				&& ( submatches.size() == 4 ) )
-			{
-				int r = StringTools::convert<int> ( submatches[1] );
-				int g = StringTools::convert<int> ( submatches[2] );
-				int b = StringTools::convert<int> ( submatches[3] );
-				long index = 256*(256*r + g) + b;
-				tbl_color_classno[index] = _classno;
-				tbl_classno_color[_classno] = index;
-			} else {
-				fprintf (stderr, "LabeledFileList: parse error colors >%s<\n", value.c_str() );
-				exit(-1);
-			}
-		}
-	}
-
-	return true;
+      } else {
+        fprintf ( stderr, "ClassNames::ClassNames: FATAL ERROR class >%s< not found in data set\n", classname.c_str() );
+        exit ( -1 );
+      }
+    }
+  }
+
+  /****** after all, try to read color coding *******/
+  map<string, string> list;
+  datasetconf.getAllS ( "colors", list );
+
+  if ( list.size() > 0 ) {
+    for ( map<string, string>::const_iterator i = list.begin();
+          i != list.end();
+          i++ )
+    {
+      std::string value = i->second;
+      std::string classname = i->first;
+      int _classno = classno ( classname );
+      vector<string> submatches;
+      if ( StringTools::regexMatch ( value, "^ *([[:digit:]]+) *: *([[:digit:]]+) *: *([[:digit:]]+) *$", submatches )
+           && ( submatches.size() == 4 ) )
+      {
+        int r = StringTools::convert<int> ( submatches[1] );
+        int g = StringTools::convert<int> ( submatches[2] );
+        int b = StringTools::convert<int> ( submatches[3] );
+        long index = 256 * ( 256 * r + g ) + b;
+        tbl_color_classno[index] = _classno;
+        tbl_classno_color[_classno] = index;
+      } else {
+        fprintf ( stderr, "LabeledFileList: parse error colors >%s<\n", value.c_str() );
+        exit ( -1 );
+      }
+    }
+  }
+
+  return true;
 }
-	
+
 int ClassNames::getMaxClassno () const
 {
-	return maxClassNo;
+  return maxClassNo;
 }
-	
+
 void ClassNames::getRGBColor ( int classno, int & r, int & g, int & b ) const
 {
-	map<int, long>::const_iterator i = tbl_classno_color.find(classno);
-
-	if ( i == tbl_classno_color.end() )
-	{
-		fprintf (stderr, "ClassNames: no color setting found for class %d\n", classno );
-		getchar();
-		double x = classno / (double)numClasses();
-		double rd, gd, bd;
-		ICETools::toColor ( x, rd, gd, bd );
-		r = (int)(255*rd);
-		g = (int)(255*gd);
-		b = (int)(255*bd);
-	} else {
-		long color = i->second;
-		b = color % 256;
-		color /= 256;
-		g = color % 256;
-		color /= 256;
-		r = color % 256;
-	}
+  map<int, long>::const_iterator i = tbl_classno_color.find ( classno );
+
+  if ( i == tbl_classno_color.end() )
+  {
+    fprintf ( stderr, "ClassNames: no color setting found for class %d\n", classno );
+    getchar();
+    double x = classno / ( double ) numClasses();
+    double rd, gd, bd;
+    ICETools::toColor ( x, rd, gd, bd );
+    r = ( int ) ( 255 * rd );
+    g = ( int ) ( 255 * gd );
+    b = ( int ) ( 255 * bd );
+  } else {
+    long color = i->second;
+    b = color % 256;
+    color /= 256;
+    g = color % 256;
+    color /= 256;
+    r = color % 256;
+  }
 }
 
 void ClassNames::getClassnoFromColor ( int & classno, int r, int g, int b ) const
 {
-	long color = 256*(256*r+g) + b;
-	map<long, int>::const_iterator i = tbl_color_classno.find(color);
-
-	if ( i == tbl_color_classno.end() )
-	{
-		classno = -1;
-	} else {
-		classno = i->second;
-	}
+  long color = 256 * ( 256 * r + g ) + b;
+  map<long, int>::const_iterator i = tbl_color_classno.find ( color );
+
+  if ( i == tbl_color_classno.end() )
+  {
+    classno = -1;
+  } else {
+    classno = i->second;
+  }
 }
 
 void ClassNames::labelToRGB ( const NICE::Image & img, NICE::ColorImage & rgb ) const
 {
-	int red, green, blue;
+  int red, green, blue;
 
-	rgb.resize(img.width(), img.height());
+  rgb.resize ( img.width(), img.height() );
 
-	for ( int y = 0 ; y < img.height(); y++ )
-	for ( int x = 0 ; x < img.width(); x++ )
-	{
-		int label = img.getPixel(x,y);
-		getRGBColor ( label, red, green, blue );
-		rgb.setPixel(x,y,0,red);
-		rgb.setPixel(x,y,1,green);
-		rgb.setPixel(x,y,2,blue);
-	}
+  for ( int y = 0 ; y < img.height(); y++ )
+    for ( int x = 0 ; x < img.width(); x++ )
+    {
+      int label = img.getPixel ( x, y );
+      getRGBColor ( label, red, green, blue );
+      rgb.setPixel ( x, y, 0, red );
+      rgb.setPixel ( x, y, 1, green );
+      rgb.setPixel ( x, y, 2, blue );
+    }
 
 }
 
 int ClassNames::getBackgroundClass () const
 {
-	if ( existsClassCode ("various" ) )
-		return classno("various");
-	else if ( existsClassCode ("background" ) )
-		return classno("background");
-	else if ( existsClassCode ("clutter" ) )
-		return classno("clutter");
-	else
-		return 0;
+  if ( existsClassCode ( "various" ) )
+    return classno ( "various" );
+  else if ( existsClassCode ( "background" ) )
+    return classno ( "background" );
+  else if ( existsClassCode ( "clutter" ) )
+    return classno ( "clutter" );
+  else
+    return 0;
 }
 
-void ClassNames::restore (istream & is, int format)
+void ClassNames::restore ( istream & is, int format )
 {
-	maxClassNo = -1;
-	while ( ! is.eof() )
-	{
-		std::string mytext;
-		std::string mycode;
-		int myclassno;
-
-		if ( !(is >> mytext) ) break;
-		if ( !(is >> mycode) ) break;
-		if ( !(is >> myclassno) ) break;
-
-		tbl_code_text.insert ( pair<string, string> ( mycode, mytext ) );
-		tbl_text_code.insert ( pair<string, string> ( mytext, mycode ) );
-		tbl_classno_code.insert ( pair<int, string> ( myclassno, mycode ) );
-		tbl_code_classno.insert ( pair<string, int> ( mycode, myclassno ) );
-
-		if ( myclassno > maxClassNo ) maxClassNo = myclassno;
-	}
+  maxClassNo = -1;
+  while ( ! is.eof() )
+  {
+    std::string mytext;
+    std::string mycode;
+    int myclassno;
+
+    if ( ! ( is >> mytext ) ) break;
+    if ( mytext == "end" ) break;
+    if ( ! ( is >> mycode ) ) break;
+    if ( ! ( is >> myclassno ) ) break;
+
+    tbl_code_text.insert ( pair<string, string> ( mycode, mytext ) );
+    tbl_text_code.insert ( pair<string, string> ( mytext, mycode ) );
+    tbl_classno_code.insert ( pair<int, string> ( myclassno, mycode ) );
+    tbl_code_classno.insert ( pair<string, int> ( mycode, myclassno ) );
+
+    if ( myclassno > maxClassNo ) maxClassNo = myclassno;
+  }
 }
 
-void ClassNames::store (ostream & os, int format) const
+void ClassNames::store ( ostream & os, int format ) const
 {
-	assert ( tbl_classno_code.size() == tbl_code_classno.size() );
-	for ( map<int, string>::const_iterator i  = tbl_classno_code.begin() ;
-						  i != tbl_classno_code.end();
-						  i++ )
-	{
-		int myclassno = i->first;
-		std::string mycode = i->second;
-		std::string mytext = text(myclassno);
-
-		os << mytext << "\t" << mycode << "\t" << myclassno << endl;
-	}	
+  assert ( tbl_classno_code.size() == tbl_code_classno.size() );
+  for ( map<int, string>::const_iterator i  = tbl_classno_code.begin() ;
+        i != tbl_classno_code.end();
+        i++ )
+  {
+    int myclassno = i->first;
+    std::string mycode = i->second;
+    std::string mytext = text ( myclassno );
+
+    os << mytext << "\t" << mycode << "\t" << myclassno << endl;
+  }
+  os << "end" << endl;
 }
 
 void ClassNames::clear ()
 {
-	tbl_code_text.clear();
-	tbl_text_code.clear();
-	tbl_classno_code.clear();
-	tbl_code_classno.clear();
-	tbl_color_classno.clear();
-	tbl_classno_color.clear();
+  tbl_code_text.clear();
+  tbl_text_code.clear();
+  tbl_classno_code.clear();
+  tbl_code_classno.clear();
+  tbl_color_classno.clear();
+  tbl_classno_color.clear();
 }
 

+ 80 - 80
cbaselib/ClassNames.h

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file ClassNames.h
 * @brief simple interface for class name confusion
 * @author Erik Rodner
@@ -11,7 +11,7 @@
 #include "core/image/ImageT.h"
 #include "core/vector/VectorT.h"
 #include "core/vector/MatrixT.h"
- 
+
 #include <string>
 #include <map>
 
@@ -25,84 +25,84 @@ namespace OBJREC {
 class ClassNames : public NICE::Persistent
 {
 
-    protected:
-
-		std::map<std::string, std::string> tbl_code_text;
-		std::map<std::string, std::string> tbl_text_code;
-		std::map<int, std::string> tbl_classno_code;
-		std::map<std::string, int> tbl_code_classno;
-		std::map<long, int> tbl_color_classno;
-		std::map<int, long> tbl_classno_color;
-
-		int maxClassNo;
-
-    public:
-  
-	/** simple constructor */
-	ClassNames();
-    
-	/** copy constructor */
-	ClassNames ( const ClassNames & cn );
-  
-	/** create sub selection */
-	ClassNames ( const ClassNames & cn, 
-		     const std::string & classselection );
-
-	/** simple destructor */
-	virtual ~ClassNames();
-    
-	/** get the readable class number of a class number */
-	std::string text ( int classno ) const;
-
-	/** get the class code (e.g. ascii code) of a class number */
-	std::string code ( int classno ) const;
-
-	/** get the class number corresponding to the code */
-	int classno ( std::string code ) const;
-	
-	/** get the class number corresponding to the name */
-	int classnoFromText ( std::string text ) const;
-
-	/** number of classes */
-	int numClasses () const;
-	void getSelection ( const std::string & classselection,
-			    std::set<int> & classnos ) const;
-
-	/** add new class information 
-	 * @param classno class number
-	 * @param code class code (such as ascii number or just the name)
-	 * @param text class name as readable ascii representation
-	 */
-	void addClass ( int classno, const std::string & code, 
-	    const std::string & text );
-
-	bool readFromConfig ( const NICE::Config & datasetconf, 
-		    const std::string & classselection );
-
-	/** is there any class with this class number */
-	bool existsClassno ( int classno ) const;
-	/** is there any class with this class code */
-	bool existsClassCode ( const std::string & classcode ) const;
-
-	int getMaxClassno () const;
-
-	void getRGBColor ( int classno, int & r, int & g, int & b ) const;
-	
-	void getClassnoFromColor ( int & classno, int r, int g, int b ) const;
-
-	/** colorize a labeled image using color information given in the class 
-	 *  information file */
-	void labelToRGB ( const NICE::Image & img, NICE::ColorImage & rgb ) const;
-
-	int getBackgroundClass () const;
-
-	/** restore classnames in the format <classtext> <classcode> <classno> */ 
-	void restore (std::istream & is, int format = 0);
-
-	/** store classnames in the format <classtext> <classcode> <classno> */ 
-	void store (std::ostream & os, int format = 0) const;
-
-	/** clear class information */
+  protected:
+
+    std::map<std::string, std::string> tbl_code_text;
+    std::map<std::string, std::string> tbl_text_code;
+    std::map<int, std::string> tbl_classno_code;
+    std::map<std::string, int> tbl_code_classno;
+    std::map<long, int> tbl_color_classno;
+    std::map<int, long> tbl_classno_color;
+
+    int maxClassNo;
+
+  public:
+
+    /** simple constructor */
+    ClassNames();
+
+    /** copy constructor */
+    ClassNames ( const ClassNames & cn );
+
+    /** create sub selection */
+    ClassNames ( const ClassNames & cn,
+                 const std::string & classselection );
+
+    /** simple destructor */
+    virtual ~ClassNames();
+
+    /** get the readable class number of a class number */
+    std::string text ( int classno ) const;
+
+    /** get the class code (e.g. ascii code) of a class number */
+    std::string code ( int classno ) const;
+
+    /** get the class number corresponding to the code */
+    int classno ( std::string code ) const;
+
+    /** get the class number corresponding to the name */
+    int classnoFromText ( std::string text ) const;
+
+    /** number of classes */
+    int numClasses () const;
+    void getSelection ( const std::string & classselection,
+                        std::set<int> & classnos ) const;
+
+    /** add new class information
+     * @param classno class number
+     * @param code class code (such as ascii number or just the name)
+     * @param text class name as readable ascii representation
+     */
+    void addClass ( int classno, const std::string & code,
+                    const std::string & text );
+
+    bool readFromConfig ( const NICE::Config & datasetconf,
+                          const std::string & classselection );
+
+    /** is there any class with this class number */
+    bool existsClassno ( int classno ) const;
+    /** is there any class with this class code */
+    bool existsClassCode ( const std::string & classcode ) const;
+
+    int getMaxClassno () const;
+
+    void getRGBColor ( int classno, int & r, int & g, int & b ) const;
+
+    void getClassnoFromColor ( int & classno, int r, int g, int b ) const;
+
+    /** colorize a labeled image using color information given in the class
+     *  information file */
+    void labelToRGB ( const NICE::Image & img, NICE::ColorImage & rgb ) const;
+
+    int getBackgroundClass () const;
+
+    /** restore classnames in the format <classtext> <classcode> <classno> */
+    void restore ( std::istream & is, int format = 0 );
+
+    /** store classnames in the format <classtext> <classcode> <classno> */
+    void store ( std::ostream & os, int format = 0 ) const;
+
+    /** clear class information */
     void clear ();
 };
 

+ 76 - 76
classifier/genericClassifierSelection.h

@@ -51,92 +51,92 @@ namespace OBJREC {
 
 class GenericClassifierSelection
 {
-    public:
+  public:
 
-		static VecClassifier *selectVecClassifier ( const NICE::Config *conf, std::string classifier_type )
-		{
-			 std::vector<std::string> submatches;
-			 VecClassifier *classifier = NULL;
+    static VecClassifier *selectVecClassifier ( const NICE::Config *conf, std::string classifier_type )
+    {
+      std::vector<std::string> submatches;
+      VecClassifier *classifier = NULL;
 
-			 if ( classifier_type == "amit" ) {
-				  classifier = new VCAmitSVM ( conf );
+      if ( classifier_type == "amit" ) {
+        classifier = new VCAmitSVM ( conf );
 
-			 } else if ( classifier_type == "nn" ) {
-				  classifier = new VCNearestNeighbour( conf, new NICE::EuclidianDistance<double>() );
-#ifdef NICE_USELIB_ICE 
-			 } else if ( classifier_type == "gauss" ) {
-				  classifier = new VCSimpleGaussian( conf );
+      } else if ( classifier_type == "nn" ) {
+        classifier = new VCNearestNeighbour ( conf, new NICE::EuclidianDistance<double>() );
+#ifdef NICE_USELIB_ICE
+      } else if ( classifier_type == "gauss" ) {
+        classifier = new VCSimpleGaussian ( conf );
 #endif
-			 } else if ( classifier_type == "random_forest" ) {
-				  FeaturePoolClassifier *fpc = new FPCRandomForests ( conf, "RandomForest" );
-				  classifier = new VCFeaturePool ( conf, fpc );
-				
-			 } else if ( classifier_type == "sparse_logistic_regression" ) {
-				 FeaturePoolClassifier *fpc = new FPCSMLR ( conf, "SparseLogisticRegression" );
-				 classifier = new VCFeaturePool ( conf, fpc );
-				  
-			 } else if ( classifier_type == "boost" ) {
-				  FeaturePoolClassifier *fpc = new FPCBoosting ( conf, "Boost" );
-				  classifier = new VCFeaturePool ( conf, fpc );
-			 
-				 } else if ( classifier_type == "decision_tree" ) {
-				  FeaturePoolClassifier *fpc = new FPCDecisionTree ( conf, "DecisionTree" );
-				  classifier = new VCFeaturePool ( conf, fpc );
+      } else if ( classifier_type == "random_forest" ) {
+        FeaturePoolClassifier *fpc = new FPCRandomForests ( conf, "RandomForest" );
+        classifier = new VCFeaturePool ( conf, fpc );
+
+      } else if ( classifier_type == "sparse_logistic_regression" ) {
+        FeaturePoolClassifier *fpc = new FPCSMLR ( conf, "SparseLogisticRegression" );
+        classifier = new VCFeaturePool ( conf, fpc );
+
+      } else if ( classifier_type == "boost" ) {
+        FeaturePoolClassifier *fpc = new FPCBoosting ( conf, "Boost" );
+        classifier = new VCFeaturePool ( conf, fpc );
+
+      } else if ( classifier_type == "decision_tree" ) {
+        FeaturePoolClassifier *fpc = new FPCDecisionTree ( conf, "DecisionTree" );
+        classifier = new VCFeaturePool ( conf, fpc );
 #ifdef NICE_USELIB_ICE
-			 } else if ( (classifier_type == "cross_generalization") || (classifier_type == "bart") ) {
-				  classifier = new VCCrossGeneralization ( conf );
+      } else if ( ( classifier_type == "cross_generalization" ) || ( classifier_type == "bart" ) ) {
+        classifier = new VCCrossGeneralization ( conf );
 #endif
 #ifdef NICE_USELIB_SVMLIGHT
-			 } else if ( (classifier_type == "svmlight") || (classifier_type == "svm") ) {
-				  classifier = new VCSVMLight ( conf );
-			 } else if ( (classifier_type == "svm_onevsone") ) {
-				  classifier = new VCOneVsOne ( conf, new VCSVMLight(conf) );
-			 } else if ( (classifier_type == "svm_onevsall") ) {
-				  classifier = new VCOneVsAll ( conf, new VCSVMLight(conf) );
-			 } else if ( (classifier_type == "svmlight_kernel")) {
-				  classifier = new KCSVMLight ( conf, new KernelStd() );
-			 } else if ( (classifier_type == "svm_one_class")) {
-				  classifier = new VCSVMOneClass( conf, "VCSVMLight" );
+      } else if ( ( classifier_type == "svmlight" ) || ( classifier_type == "svm" ) ) {
+        classifier = new VCSVMLight ( conf );
+      } else if ( ( classifier_type == "svm_onevsone" ) ) {
+        classifier = new VCOneVsOne ( conf, new VCSVMLight ( conf ) );
+      } else if ( ( classifier_type == "svm_onevsall" ) ) {
+        classifier = new VCOneVsAll ( conf, new VCSVMLight ( conf ) );
+      } else if ( ( classifier_type == "svmlight_kernel" ) ) {
+        classifier = new KCSVMLight ( conf, new KernelStd() );
+      } else if ( ( classifier_type == "svm_one_class" ) ) {
+        classifier = new VCSVMOneClass ( conf, "VCSVMLight" );
 #endif
 #ifdef NICE_USELIB_NICEDTSVM
-			 // this classifier requires nice-dtsvm, which is an optional
-			 // nice sub-library
-			 } else if ( classifier_type == "treebased" ) {
-				 classifier = new VCTreeBasedClassifier ( conf );
+        // this classifier requires nice-dtsvm, which is an optional
+        // nice sub-library
+      } else if ( classifier_type == "treebased" ) {
+        classifier = new VCTreeBasedClassifier ( conf );
 #endif
-			 } else if ( (classifier_type == "dtgp") ) {
-				  classifier = new VCDTSVM ( conf );
-			 } else if ( (classifier_type == "minimum_enclosing_ball")) {
-				  string kernel_type = conf->gS("Kernel", "kernel_function", "rbf" );
-				  classifier = new KCMinimumEnclosingBall ( conf, GenericKernelSelection::selectKernel ( conf, kernel_type ) );
-			 } else if ( (classifier_type == "gp_one_class")) {
-				  string kernel_type = conf->gS("Kernel", "kernel_function", "rbf" );
-				  classifier = new KCGPOneClass ( conf, GenericKernelSelection::selectKernel ( conf, kernel_type ) );
-			 } else if ( (classifier_type == "gp_regression_rbf")) {
-				  string kernel_type = conf->gS("Kernel", "kernel_function", "rbf" );
-				  classifier = new KCGPRegression ( conf, GenericKernelSelection::selectKernel ( conf, kernel_type ) );
-			 } else if ( (classifier_type == "gp_laplace_rbf")) {
-				  string kernel_type = conf->gS("Kernel", "kernel_function", "rbf" );
-				  classifier = new KCGPLaplace ( conf, GenericKernelSelection::selectKernel ( conf, kernel_type ) );
-			 } else if ( (classifier_type == "gp_regression_rbf_onevsall" ) ) {
-				  string kernel_type = conf->gS("Kernel", "kernel_function", "rbf" );
-				  classifier = new KCGPRegOneVsAll ( conf, GenericKernelSelection::selectKernel ( conf, kernel_type ) );
-			 } else if ( (classifier_type == "gp_laplace_rbf_onevsall" ) ) {
-				  string kernel_type = conf->gS("Kernel", "kernel_function", "rbf" );
-				  classifier = new KCGPLaplaceOneVsAll ( conf, GenericKernelSelection::selectKernel ( conf, kernel_type ) );
-			 } else if ( StringTools::regexMatch ( classifier_type, "^one_vs_one\\(([^\\)]+)\\)$", submatches ) && (submatches.size() == 2)) {
-				  classifier = new VCOneVsOne ( conf, selectVecClassifier( conf, submatches[1] ) );
-			 } else if ( StringTools::regexMatch ( classifier_type, "^one_vs_all\\(([^\\)]+)\\)$", submatches ) && (submatches.size() == 2)) {
-				  classifier = new VCOneVsAll ( conf, selectVecClassifier( conf, submatches[1] ) );
-			 } else if ( StringTools::regexMatch ( classifier_type, "^random_forest\\(([^\\)]+)\\)$", submatches ) && (submatches.size() == 2)) {
-				  classifier = new VCPreRandomForest ( conf, "VCPreRandomForest", selectVecClassifier(conf, submatches[1] ) );
-			 } else {
-				  fthrow ( Exception, "Classifier type " << classifier_type << " not (yet) supported." << endl <<
-				  			"(genericClassifierSelection.h contains a list of classifiers to choose from)");
-			 }
-
-			 return classifier;
-		}
+      } else if ( ( classifier_type == "dtgp" ) ) {
+        classifier = new VCDTSVM ( conf );
+      } else if ( ( classifier_type == "minimum_enclosing_ball" ) ) {
+        string kernel_type = conf->gS ( "Kernel", "kernel_function", "rbf" );
+        classifier = new KCMinimumEnclosingBall ( conf, GenericKernelSelection::selectKernel ( conf, kernel_type ) );
+      } else if ( ( classifier_type == "gp_one_class" ) ) {
+        string kernel_type = conf->gS ( "Kernel", "kernel_function", "rbf" );
+        classifier = new KCGPOneClass ( conf, GenericKernelSelection::selectKernel ( conf, kernel_type ) );
+      } else if ( ( classifier_type == "gp_regression_rbf" ) ) {
+        string kernel_type = conf->gS ( "Kernel", "kernel_function", "rbf" );
+        classifier = new KCGPRegression ( conf, GenericKernelSelection::selectKernel ( conf, kernel_type ) );
+      } else if ( ( classifier_type == "gp_laplace_rbf" ) ) {
+        string kernel_type = conf->gS ( "Kernel", "kernel_function", "rbf" );
+        classifier = new KCGPLaplace ( conf, GenericKernelSelection::selectKernel ( conf, kernel_type ) );
+      } else if ( ( classifier_type == "gp_regression_rbf_onevsall" ) ) {
+        string kernel_type = conf->gS ( "Kernel", "kernel_function", "rbf" );
+        classifier = new KCGPRegOneVsAll ( conf, GenericKernelSelection::selectKernel ( conf, kernel_type ) );
+      } else if ( ( classifier_type == "gp_laplace_rbf_onevsall" ) ) {
+        string kernel_type = conf->gS ( "Kernel", "kernel_function", "rbf" );
+        classifier = new KCGPLaplaceOneVsAll ( conf, GenericKernelSelection::selectKernel ( conf, kernel_type ) );
+      } else if ( StringTools::regexMatch ( classifier_type, "^one_vs_one\\(([^\\)]+)\\)$", submatches ) && ( submatches.size() == 2 ) ) {
+        classifier = new VCOneVsOne ( conf, selectVecClassifier ( conf, submatches[1] ) );
+      } else if ( StringTools::regexMatch ( classifier_type, "^one_vs_all\\(([^\\)]+)\\)$", submatches ) && ( submatches.size() == 2 ) ) {
+        classifier = new VCOneVsAll ( conf, selectVecClassifier ( conf, submatches[1] ) );
+      } else if ( StringTools::regexMatch ( classifier_type, "^random_forest\\(([^\\)]+)\\)$", submatches ) && ( submatches.size() == 2 ) ) {
+        classifier = new VCPreRandomForest ( conf, "VCPreRandomForest", selectVecClassifier ( conf, submatches[1] ) );
+      } else {
+        fthrow ( Exception, "Classifier type " << classifier_type << " not (yet) supported." << endl <<
+                 "(genericClassifierSelection.h contains a list of classifiers to choose from)" );
+      }
+
+      return classifier;
+    }
 
 };
 

+ 156 - 156
classifier/vclassifier/VCDTSVM.cpp

@@ -11,78 +11,78 @@ using namespace OBJREC;
 using namespace std;
 using namespace NICE;
 
-VCDTSVM::VCDTSVM ( const Config *_conf, const string & section ) 
+VCDTSVM::VCDTSVM ( const Config *_conf, const string & section )
     : VecClassifier ( _conf )
 {
-    binary = _conf->gS(section, "binary", "./tdsvm");
-    configtrain = _conf->gS(section, "configtrain", "configtrain.txt");
-    configtest = _conf->gS(section, "configtest", "configtest.txt");
-    trainfile  = _conf->gS(section, "traindst", "train.txt");
-    testfile  = _conf->gS(section, "testdst", "test.txt");
+  binary = _conf->gS ( section, "binary", "./tdsvm" );
+  configtrain = _conf->gS ( section, "configtrain", "configtrain.txt" );
+  configtest = _conf->gS ( section, "configtest", "configtest.txt" );
+  trainfile  = _conf->gS ( section, "traindst", "train.txt" );
+  testfile  = _conf->gS ( section, "testdst", "test.txt" );
 
 #ifndef WRITE
-    counter = new vector<int>(1,0);
-    if(results.size() == 0)
+  counter = new vector<int> ( 1, 0 );
+  if ( results.size() == 0 )
+  {
+
+    ifstream fin ( "results.txt" );
+
+
+    const int bufsize = 1024 * 1024;
+    char *buf = new char[bufsize];
+    std::string buf_s;
+    while ( !fin.eof() )
     {
+      int bc;
+      vector<string> elements;
+      fin >> bc;
+      fin.get ( buf, bufsize );
+      buf_s = buf;
+
+      if ( buf_s.size() <= 0 )
+        break;
+
+      StringTools::split ( buf_s, ' ', elements );
 
-	    ifstream fin("results.txt");
-		
-
-	    const int bufsize = 1024*1024;
-	    char *buf = new char[bufsize];
-	    std::string buf_s;	
-	    while(!fin.eof())
-	    {
-		    int bc;
-		    vector<string> elements;
-		    fin >> bc;
-		    fin.get ( buf, bufsize );
-		    buf_s = buf;
-	
-		    if ( buf_s.size() <= 0 ) 
-			    break;
-	
-		    StringTools::split ( buf_s, ' ', elements );
-	
-		    if ( elements.size() <= 1 )
-			    break;
-	
-		    vector<double> tmp;
-	
-		    size_t l = 0;
-			
-			// skip first element because of white space
-		    for ( vector<string>::const_iterator i  = elements.begin()+1; i != elements.end(); i++, l++ )
-		    {
-			    double val = atof ( i->c_str() );
-			    tmp.push_back(val);
-		    }
-		    results.push_back(tmp);
-		    labels.push_back(bc);
-	    }
-
-	    fin.close();
-
-	    (*counter)[0] = 0;
-	    //counter = 0;
+      if ( elements.size() <= 1 )
+        break;
+
+      vector<double> tmp;
+
+      size_t l = 0;
+
+      // skip first element because of white space
+      for ( vector<string>::const_iterator i  = elements.begin() + 1; i != elements.end(); i++, l++ )
+      {
+        double val = atof ( i->c_str() );
+        tmp.push_back ( val );
+      }
+      results.push_back ( tmp );
+      labels.push_back ( bc );
     }
+
+    fin.close();
+
+    ( *counter ) [0] = 0;
+    //counter = 0;
+  }
 #endif
 }
 
-VCDTSVM::VCDTSVM ( const VCDTSVM & classifier ) : VecClassifier() 
+VCDTSVM::VCDTSVM ( const VCDTSVM & classifier ) : VecClassifier()
 {
-	binary = classifier.binary;
-	configtrain = classifier.configtrain;
-	configtest = classifier.configtest;
-	trainfile = classifier.trainfile;
-	testfile = classifier.testfile;
+  binary = classifier.binary;
+  configtrain = classifier.configtrain;
+  configtest = classifier.configtest;
+  trainfile = classifier.trainfile;
+  testfile = classifier.testfile;
 }
 
 
 VCDTSVM::~VCDTSVM()
 {
-	int c2 = (*counter)[0];
-	cout << "c2: " << c2 << " matsize " << results.size() << endl;
+  int c2 = ( *counter ) [0];
+  cout << "c2: " << c2 << " matsize " << results.size() << endl;
 }
 
 ClassificationResult VCDTSVM::classify ( const NICE::Vector & x ) const
@@ -90,105 +90,105 @@ ClassificationResult VCDTSVM::classify ( const NICE::Vector & x ) const
 
 
 #ifdef WRITE
-	ofstream fout( testfile.c_str(), ios::app );
-	fout << 0 << " ";
-	int i;
-	for(i = 0; i < x.size()-1; i++)
-	{
-		fout << i+1 << ":" << x[i] << " ";
-	}
-	i++;
-	fout << i+1 << ":" << x[i] << endl;
-	fout.close();
-	
-	
-	FullVector scores(10);
-
-	//scores.read("scores");
-	double bval = scores[0];
-
-	int bclass = 0;
-	for(i = 1; i < scores.size(); i++)
-	{
-		if(bval < scores[i])
-		{
-			bval = scores[i];
-			bclass = i;
-		}
-	}
-	return ClassificationResult (bclass, scores);
+  ofstream fout ( testfile.c_str(), ios::app );
+  fout << 0 << " ";
+  int i;
+  for ( i = 0; i < x.size() - 1; i++ )
+  {
+    fout << i + 1 << ":" << x[i] << " ";
+  }
+  i++;
+  fout << i + 1 << ":" << x[i] << endl;
+  fout.close();
+
+
+  FullVector scores ( 10 );
+
+  //scores.read("scores");
+  double bval = scores[0];
+
+  int bclass = 0;
+  for ( i = 1; i < scores.size(); i++ )
+  {
+    if ( bval < scores[i] )
+    {
+      bval = scores[i];
+      bclass = i;
+    }
+  }
+  return ClassificationResult ( bclass, scores );
 #endif
-	
+
 #ifndef WRITE
-	int c2 = (*counter)[0];
-	(*counter)[0]++;
-	FullVector tmp(results[c2].size());
-	for(int i = 0; i < results[c2].size(); i++)
-	{
-		tmp[i] = results[c2][i];
-	}
-	return ClassificationResult (labels[c2], tmp);	
+  int c2 = ( *counter ) [0];
+  ( *counter ) [0]++;
+  FullVector tmp ( results[c2].size() );
+  for ( int i = 0; i < results[c2].size(); i++ )
+  {
+    tmp[i] = results[c2][i];
+  }
+  return ClassificationResult ( labels[c2], tmp );
 #endif
 
-#if 0	
-	const int buffersize = 65536;
-	char *buffer = new char [buffersize];
-	
-	string call = binary +" "+configtest;
-	
-	FILE *f = popen ( call.c_str(), "r" );
-	
-	if ( f == NULL )
-	{
-		fprintf (stderr, "VCDTSVM::classify: FATAL ERROR, unable to run the implementation of DTSVM\n");
-		exit(-1);
-	}
-	
-	while ( ! feof(f) ) 
-	{
-		if ( fgets ( buffer, buffersize, f ) <= 0 )
-		{
-			break;
-		} else 
-		{
-			//fprintf (stderr, "VCDTSVM::classify: [INFO] %s", buffer );
-		}
-	}
-	pclose(f);
+#if 0
+  const int buffersize = 65536;
+  char *buffer = new char [buffersize];
+
+  string call = binary + " " + configtest;
+
+  FILE *f = popen ( call.c_str(), "r" );
+
+  if ( f == NULL )
+  {
+    fprintf ( stderr, "VCDTSVM::classify: FATAL ERROR, unable to run the implementation of DTSVM\n" );
+    exit ( -1 );
+  }
+
+  while ( ! feof ( f ) )
+  {
+    if ( fgets ( buffer, buffersize, f ) <= 0 )
+    {
+      break;
+    } else
+    {
+      //fprintf (stderr, "VCDTSVM::classify: [INFO] %s", buffer );
+    }
+  }
+  pclose ( f );
 #endif
 }
 
 void VCDTSVM::teach ( const LabeledSetVector & _teachSet )
 {
-    	maxClassNo = _teachSet.getMaxClassno();
-    	//TODO: LabeledSet rausschreiben und classifier anwerfen
+  maxClassNo = _teachSet.getMaxClassno();
+  //TODO: LabeledSet rausschreiben und classifier anwerfen
 #ifdef WRITE
-    	_teachSet.write(trainfile, LabeledSetVector::FILEFORMAT_INDEX);
-    /*
-    	string call = binary +" "+configtrain;
-    
-    	const int buffersize = 65536;
-	char *buffer = new char [buffersize];
-	
-	FILE *f = popen ( call.c_str(), "r" );
-	
-	if ( f == NULL )
-	{
-		fprintf (stderr, "VCDTSVM::teach: FATAL ERROR, unable to run the implementation of DTSVM\n");
-		exit(-1);
-	}
-	
-	while ( ! feof(f) ) 
-	{
-		if ( fgets ( buffer, buffersize, f ) <= 0 )
-		{
-			break;
-		} else 
-		{
-			fprintf (stderr, "VCDTSVM::teach: [INFO] %s", buffer );
-		}
-	}
-	pclose(f);*/
+  _teachSet.write ( trainfile, LabeledSetVector::FILEFORMAT_INDEX );
+  /*
+   string call = binary +" "+configtrain;
+
+   const int buffersize = 65536;
+  char *buffer = new char [buffersize];
+
+  FILE *f = popen ( call.c_str(), "r" );
+
+  if ( f == NULL )
+  {
+  fprintf (stderr, "VCDTSVM::teach: FATAL ERROR, unable to run the implementation of DTSVM\n");
+  exit(-1);
+  }
+
+  while ( ! feof(f) )
+  {
+  if ( fgets ( buffer, buffersize, f ) <= 0 )
+  {
+  break;
+  } else
+  {
+  fprintf (stderr, "VCDTSVM::teach: [INFO] %s", buffer );
+  }
+  }
+  pclose(f);*/
 #endif
 }
 
@@ -197,35 +197,35 @@ void VCDTSVM::finishTeaching()
 }
 
 /** clone this object */
-VCDTSVM *VCDTSVM::clone(void) const
+VCDTSVM *VCDTSVM::clone ( void ) const
 {
-	VCDTSVM *classifier = new VCDTSVM( *this );
-	return classifier;
+  VCDTSVM *classifier = new VCDTSVM ( *this );
+  return classifier;
 }
 
 void VCDTSVM::clear ()
 {
-    //TODO wieder freigeben
+  //TODO wieder freigeben
 }
 
-void VCDTSVM::read (const string& s, int format)
+void VCDTSVM::read ( const string& s, int format )
 {
-    //TODO: Zielverzeichnis eventuell
+  //TODO: Zielverzeichnis eventuell
 }
 
-void VCDTSVM::save (const string& s, int format) const
+void VCDTSVM::save ( const string& s, int format ) const
 {
-    //TODO: Zielverzeichnis eventuell
+  //TODO: Zielverzeichnis eventuell
 }
 
 
 void VCDTSVM::store ( std::ostream & os, int format ) const
 {
-    fprintf (stderr, "VCDTSVM: unable to write to stream! please use read()\n");
+  fprintf ( stderr, "VCDTSVM: unable to write to stream! please use read()\n" );
 }
 
 void VCDTSVM::restore ( std::istream & is, int format )
 {
-    fprintf (stderr, "VCDTSVM: unable to read from stream! please use save()\n");
-    exit (-1);
+  fprintf ( stderr, "VCDTSVM: unable to read from stream! please use save()\n" );
+  exit ( -1 );
 }

+ 50 - 50
classifier/vclassifier/VCDTSVM.h

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file VCDTSVM.h
 * @brief Interface to DTSVM
 * @author Björn Fröhlich
@@ -20,55 +20,55 @@ namespace OBJREC {
 class VCDTSVM : public VecClassifier
 {
 
-	protected:
-		NICE::Vector max;
-		NICE::Vector min;
-
-		int normalization_type;
-		
-		/** where to find the binary file */
-		std::string binary;
-		
-		/** where to find the DT-SVM config files */
-		std::string configtrain;
-		std::string configtest;
-		std::string trainfile;
-		std::string testfile;
-		
-	private:
-		std::vector<std::vector<double> > results;
-		std::vector<int> *counter;
-		//int counter;
-		std::vector<int> labels;		
-
-	public:
-		/** using a config file to read some settings */
-		VCDTSVM( const NICE::Config *conf, const std::string & section = "VCDTSVM" );
-
-		/** simple copy constructor */
-		VCDTSVM ( const VCDTSVM & src );
-	  
-		/** simple destructor */
-		virtual ~VCDTSVM();
-		 
-		/** classify using simple vector */
-		ClassificationResult classify ( const NICE::Vector & x ) const;
-
-		/** classify using a simple vector */
-		void teach ( const LabeledSetVector & teachSet );
-		
-		void finishTeaching();
-
-		/** clone this object */
-		virtual VCDTSVM *clone(void) const;
-
-		void clear ();
-
-		void read (const std::string& s, int format = 0);
-		void save (const std::string& s, int format = 0) const;
-
-		void store ( std::ostream & os, int format = 0 ) const;
-		void restore ( std::istream & is, int format = 0 );
+  protected:
+    NICE::Vector max;
+    NICE::Vector min;
+
+    int normalization_type;
+
+    /** where to find the binary file */
+    std::string binary;
+
+    /** where to find the DT-SVM config files */
+    std::string configtrain;
+    std::string configtest;
+    std::string trainfile;
+    std::string testfile;
+
+  private:
+    std::vector<std::vector<double> > results;
+    std::vector<int> *counter;
+    //int counter;
+    std::vector<int> labels;
+
+  public:
+    /** using a config file to read some settings */
+    VCDTSVM ( const NICE::Config *conf, const std::string & section = "VCDTSVM" );
+
+    /** simple copy constructor */
+    VCDTSVM ( const VCDTSVM & src );
+
+    /** simple destructor */
+    virtual ~VCDTSVM();
+
+    /** classify using simple vector */
+    ClassificationResult classify ( const NICE::Vector & x ) const;
+
+    /** classify using a simple vector */
+    void teach ( const LabeledSetVector & teachSet );
+
+    void finishTeaching();
+
+    /** clone this object */
+    virtual VCDTSVM *clone ( void ) const;
+
+    void clear ();
+
+    void read ( const std::string& s, int format = 0 );
+    void save ( const std::string& s, int format = 0 ) const;
+
+    void store ( std::ostream & os, int format = 0 ) const;
+    void restore ( std::istream & is, int format = 0 );
 };
 
 

+ 47 - 47
features/fpfeatures/HaarFeature.cpp

@@ -16,61 +16,61 @@ using namespace std;
 using namespace NICE;
 
 
-void HaarFeature::explode( FeaturePool & featurePool, bool variableWindow ) const
+void HaarFeature::explode ( FeaturePool & featurePool, bool variableWindow ) const
 {
-  HaarFeature *hf = new HaarFeature( *this );
+  HaarFeature *hf = new HaarFeature ( *this );
 
   hf->pos1 = 0;
   hf->pos2 = 0;
   hf->type = HAARTYPE_HORIZONTAL;
   for ( hf->pos1 = 0 ; hf->pos1 < hf->window_size_y - 1 ; hf->pos1 += hf->step_y )
-    featurePool.addFeature( hf->clone(), hf->step_y / ( double )( HAARTYPE_NUMTYPES * hf->window_size_y ) );
+    featurePool.addFeature ( hf->clone(), hf->step_y / ( double ) ( HAARTYPE_NUMTYPES * hf->window_size_y ) );
 
   hf->pos1 = 0;
   hf->pos2 = 0;
   hf->type = HAARTYPE_VERTICAL;
   for ( hf->pos1 = 0 ; hf->pos1 < hf->window_size_x - 1; hf->pos1 += hf->step_x )
-    featurePool.addFeature( hf->clone(), hf->step_x / ( double )( HAARTYPE_NUMTYPES * hf->window_size_x ) );
+    featurePool.addFeature ( hf->clone(), hf->step_x / ( double ) ( HAARTYPE_NUMTYPES * hf->window_size_x ) );
 
   hf->type = HAARTYPE_DIAGONAL;
   hf->pos1 = 0;
   hf->pos2 = 0;
   for ( hf->pos1 = 0 ; hf->pos1 < hf->window_size_x - 1; hf->pos1 += hf->step_x )
     for ( hf->pos2 = 0 ; hf->pos2 < hf->window_size_y - 1 ; hf->pos2 += hf->step_y )
-      featurePool.addFeature( hf->clone(),
-                              hf->step_x * hf->step_y / ( double )( HAARTYPE_NUMTYPES * hf->window_size_x * hf->window_size_y ) );
+      featurePool.addFeature ( hf->clone(),
+                               hf->step_x * hf->step_y / ( double ) ( HAARTYPE_NUMTYPES * hf->window_size_x * hf->window_size_y ) );
 
   hf->pos1 = 0;
   hf->pos2 = 0;
   hf->type = HAARTYPE_3BLOCKS;
   for ( hf->pos1 = 0 ; hf->pos1 < hf->window_size_x - 2*hf->step_x ; hf->pos1 += hf->step_x )
     for ( hf->pos2 = hf->pos1 + hf->step_x; hf->pos2 < hf->window_size_x - hf->step_x ; hf->pos2 += hf->step_x )
-      featurePool.addFeature( hf->clone(),
-                              ( 2.0 * hf->step_x ) / ( HAARTYPE_NUMTYPES * ( hf->window_size_x - hf->step_x ) ) );
+      featurePool.addFeature ( hf->clone(),
+                               ( 2.0 * hf->step_x ) / ( HAARTYPE_NUMTYPES * ( hf->window_size_x - hf->step_x ) ) );
 
   delete hf;
 }
 
 Feature *HaarFeature::clone() const
 {
-  HaarFeature *fp =  new HaarFeature( *this );
+  HaarFeature *fp =  new HaarFeature ( *this );
   return fp;
 }
 
 
 /************* HaarFeature **************/
-HaarFeature::HaarFeature( const Config *conf )
+HaarFeature::HaarFeature ( const Config *conf )
 {
-  window_size_x = conf->gI( "HaarFeature", "window_size_x", 24 );
-  window_size_y = conf->gI( "HaarFeature", "window_size_y", 24 );
-  step_x = conf->gI( "HaarFeature", "step_x", 1 );
-  step_y = conf->gI( "HaarFeature", "step_y", 1 );
+  window_size_x = conf->gI ( "HaarFeature", "window_size_x", 24 );
+  window_size_y = conf->gI ( "HaarFeature", "window_size_y", 24 );
+  step_x = conf->gI ( "HaarFeature", "step_x", 1 );
+  step_y = conf->gI ( "HaarFeature", "step_y", 1 );
 }
 
-HaarFeature::HaarFeature( int _window_size_x,
-                          int _window_size_y,
-                          int _step_x,
-                          int _step_y )
+HaarFeature::HaarFeature ( int _window_size_x,
+                           int _window_size_y,
+                           int _step_x,
+                           int _step_y )
 {
   window_size_x = _window_size_x;
   window_size_y = _window_size_y;
@@ -85,9 +85,9 @@ HaarFeature::~HaarFeature()
 {
 }
 
-double HaarFeature::val( const Example *example ) const
+double HaarFeature::val ( const Example *example ) const
 {
-  const NICE::MultiChannelImageT<long> & img = example->ce->getLChannel( CachedExample::L_INTEGRALIMAGE );
+  const NICE::MultiChannelImageT<long> & img = example->ce->getLChannel ( CachedExample::L_INTEGRALIMAGE );
 
   const long *integralImage = img.data[0];
   int xsize = img.xsize;
@@ -112,28 +112,28 @@ double HaarFeature::val( const Example *example ) const
     br = bl + ( window_size_x - 1 );
   }
 
-  assert( tl < xsize*ysize );
-  assert( tr < xsize*ysize );
+  assert ( tl < xsize*ysize );
+  assert ( tr < xsize*ysize );
   if ( br >= xsize*ysize )
   {
-    fprintf( stderr, "xsize=%d, ysize=%d, x=%d, y=%d, wsy=%d, wsx=%d\n",
-             xsize, ysize, x, y, window_size_x, window_size_y );
-    fprintf( stderr, "example: %d x %d\n",
-             example->width, example->height );
+    fprintf ( stderr, "xsize=%d, ysize=%d, x=%d, y=%d, wsy=%d, wsx=%d\n",
+              xsize, ysize, x, y, window_size_x, window_size_y );
+    fprintf ( stderr, "example: %d x %d\n",
+              example->width, example->height );
 
   }
-  assert( bl < xsize*ysize );
-  assert( br < xsize*ysize );
-  assert( pos1 >= 0 );
-  assert( pos2 >= 0 );
+  assert ( bl < xsize*ysize );
+  assert ( br < xsize*ysize );
+  assert ( pos1 >= 0 );
+  assert ( pos2 >= 0 );
 
   double value;
   if ( type == HaarFeature::HAARTYPE_HORIZONTAL )
   {
     long ml = tl + xsize * pos1;
     long mr = tr + xsize * pos1;
-    assert(( ml >= 0 ) && ( ml < xsize*ysize ) );
-    assert(( mr >= 0 ) && ( mr < xsize*ysize ) );
+    assert ( ( ml >= 0 ) && ( ml < xsize*ysize ) );
+    assert ( ( mr >= 0 ) && ( mr < xsize*ysize ) );
     value = 2 * integralImage[mr];
     value -= 2 * integralImage[ml];
     value +=   integralImage[tl];
@@ -143,8 +143,8 @@ double HaarFeature::val( const Example *example ) const
   } else if ( type == HaarFeature::HAARTYPE_VERTICAL ) {
     long mt = tl + pos1;
     long mb = bl + pos1;
-    assert(( mt >= 0 ) && ( mt < xsize*ysize ) );
-    assert(( mb >= 0 ) && ( mb < xsize*ysize ) );
+    assert ( ( mt >= 0 ) && ( mt < xsize*ysize ) );
+    assert ( ( mb >= 0 ) && ( mb < xsize*ysize ) );
 
     value = 2 * integralImage[mb];
     value -= 2 * integralImage[mt];
@@ -154,12 +154,12 @@ double HaarFeature::val( const Example *example ) const
     value -=   integralImage[br];
   } else if ( type == HaarFeature::HAARTYPE_DIAGONAL ) {
     int p2o = pos2 * xsize;
-    assert(( p2o >= 0 ) && ( p2o < xsize*ysize ) );
-    assert(( tl + pos1 >= 0 ) && ( tl + pos1 < xsize*ysize ) );
-    assert(( tl + p2o >= 0 ) && ( tl + p2o < xsize*ysize ) );
-    assert(( bl + pos1 >= 0 ) && ( bl + pos1 < xsize*ysize ) );
-    assert(( tr + p2o >= 0 ) && ( tr + p2o < xsize*ysize ) );
-    assert(( tl + pos1 + p2o >= 0 ) && ( tl + pos1 + p2o < xsize*ysize ) );
+    assert ( ( p2o >= 0 ) && ( p2o < xsize*ysize ) );
+    assert ( ( tl + pos1 >= 0 ) && ( tl + pos1 < xsize*ysize ) );
+    assert ( ( tl + p2o >= 0 ) && ( tl + p2o < xsize*ysize ) );
+    assert ( ( bl + pos1 >= 0 ) && ( bl + pos1 < xsize*ysize ) );
+    assert ( ( tr + p2o >= 0 ) && ( tr + p2o < xsize*ysize ) );
+    assert ( ( tl + pos1 + p2o >= 0 ) && ( tl + pos1 + p2o < xsize*ysize ) );
 
     value = integralImage[tl];
     value += integralImage[bl];
@@ -174,10 +174,10 @@ double HaarFeature::val( const Example *example ) const
     value += 4 * integralImage[tl + pos1 + p2o];
 
   } else if ( type == HaarFeature::HAARTYPE_3BLOCKS ) {
-    assert(( tl + pos1 >= 0 ) && ( tl + pos1 < xsize*ysize ) );
-    assert(( bl + pos2 >= 0 ) && ( bl + pos2 < xsize*ysize ) );
-    assert(( tl + pos2 >= 0 ) && ( tl + pos2 < xsize*ysize ) );
-    assert(( bl + pos1 >= 0 ) && ( bl + pos1 < xsize*ysize ) );
+    assert ( ( tl + pos1 >= 0 ) && ( tl + pos1 < xsize*ysize ) );
+    assert ( ( bl + pos2 >= 0 ) && ( bl + pos2 < xsize*ysize ) );
+    assert ( ( tl + pos2 >= 0 ) && ( tl + pos2 < xsize*ysize ) );
+    assert ( ( bl + pos1 >= 0 ) && ( bl + pos1 < xsize*ysize ) );
     value = integralImage[tl];
     value +=  integralImage[br];
     value -=  integralImage[bl];
@@ -192,12 +192,12 @@ double HaarFeature::val( const Example *example ) const
     return -1;
   }
 
-  assert( finite( value ) );
+  assert ( finite ( value ) );
 
   return value;
 }
 
-void HaarFeature::restore( istream & is, int format )
+void HaarFeature::restore ( istream & is, int format )
 {
   is >> type;
   is >> window_size_x;
@@ -206,7 +206,7 @@ void HaarFeature::restore( istream & is, int format )
   is >> pos2;
 }
 
-void HaarFeature::store( ostream & os, int format ) const
+void HaarFeature::store ( ostream & os, int format ) const
 {
   os << "HAARFEATURE" << " " << type << " "
   << window_size_x << " " << window_size_y

+ 40 - 40
features/fpfeatures/HaarFeature.h

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file HaarFeature.h
 * @brief simple haar like feature
 * @author Erik Rodner
@@ -22,45 +22,45 @@ namespace OBJREC {
 class HaarFeature : public Feature
 {
 
-    protected:
-	enum {
-	    HAARTYPE_HORIZONTAL = 0,
-	    HAARTYPE_VERTICAL,
-	    HAARTYPE_DIAGONAL,
-	    HAARTYPE_3BLOCKS,
-	    HAARTYPE_NUMTYPES
-	};
-
-	int type;
-	int pos1;
-	int pos2;
-	int step_x;
-	int step_y;
-	int window_size_x;
-	int window_size_y;
-
-    public:
-  
-	/** simple constructor */
-	HaarFeature( const NICE::Config *conf );
-      
-	/** without memory wasting config */
-	HaarFeature ( int window_size_x,	
-		      int window_size_y,
-		      int step_x,
-		      int step_y );
-
-	/** simple destructor */
-	virtual ~HaarFeature();
-     
-	virtual double val( const Example *example ) const;
-
-	void explode ( FeaturePool & featurePool, bool variableWindow ) const;
-	Feature *clone() const;
-	
-	void restore (std::istream & is, int format = 0);
-	void store (std::ostream & os, int format = 0) const;
-	void clear ();
+  protected:
+    enum {
+      HAARTYPE_HORIZONTAL = 0,
+      HAARTYPE_VERTICAL,
+      HAARTYPE_DIAGONAL,
+      HAARTYPE_3BLOCKS,
+      HAARTYPE_NUMTYPES
+    };
+
+    int type;
+    int pos1;
+    int pos2;
+    int step_x;
+    int step_y;
+    int window_size_x;
+    int window_size_y;
+
+  public:
+
+    /** simple constructor */
+    HaarFeature ( const NICE::Config *conf );
+
+    /** without memory wasting config */
+    HaarFeature ( int window_size_x,
+                  int window_size_y,
+                  int step_x,
+                  int step_y );
+
+    /** simple destructor */
+    virtual ~HaarFeature();
+
+    virtual double val ( const Example *example ) const;
+
+    void explode ( FeaturePool & featurePool, bool variableWindow ) const;
+    Feature *clone() const;
+
+    void restore ( std::istream & is, int format = 0 );
+    void store ( std::ostream & os, int format = 0 ) const;
+    void clear ();
 
 };