Forráskód Böngészése

using namespace aus header entfernt

Björn Fröhlich 13 éve
szülő
commit
240e30e51b

+ 29 - 34
cbaselib/BoundingBox.h

@@ -10,46 +10,41 @@
 
 #include "core/image/CoordT.h"
 
-using namespace NICE;
-
-namespace OBJREC {
+namespace OBJREC
+{
 
 //! \brief Contains category ID, top left and bottom right points of the bounding
-//!  box rectangle. 
+//!  box rectangle.
 class BoundingBox
 {
-public:
-	BoundingBox();
-	BoundingBox(const BoundingBox &copy);
-	~BoundingBox();
-	
-	void setTopLeft(const CoordT< int > &aTopLeft);
-	void setTopLeft(const int &x, const int &y);
-	void setBottomRight(const CoordT< int > &aBottomRight);
-	void setBottomRight(const int &x, const int &y);
-	void setWidth(const int &aWidth);
-	void setHeight(const int &aHeight);
-	void setID(const int &anID);
-	
-	CoordT< int > topLeft() const;
-	CoordT< int > bottomRight() const;
-	int width();
-	int height();
-	int id() const;
-	
-	bool isValid() const;
-	void validate();
-	
-private:
-	CoordT< int > top_left_;
-	CoordT< int > bottom_right_;
-	int id_;
+  public:
+    BoundingBox();
+    BoundingBox ( const BoundingBox &copy );
+    ~BoundingBox();
+
+    void setTopLeft ( const NICE::CoordT< int > &aTopLeft );
+    void setTopLeft ( const int &x, const int &y );
+    void setBottomRight ( const NICE::CoordT< int > &aBottomRight );
+    void setBottomRight ( const int &x, const int &y );
+    void setWidth ( const int &aWidth );
+    void setHeight ( const int &aHeight );
+    void setID ( const int &anID );
+
+    NICE::CoordT< int > topLeft() const;
+    NICE::CoordT< int > bottomRight() const;
+    int width();
+    int height();
+    int id() const;
+
+    bool isValid() const;
+    void validate();
+
+  private:
+    NICE::CoordT< int > top_left_;
+    NICE::CoordT< int > bottom_right_;
+    int id_;
 };
 
 } //namespace
 
 #endif /* __BOUNDINGBOX_H__ */
-
-/*
- * 
- */

+ 273 - 248
cbaselib/CachedExample.h

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file CachedExample.h
 * @brief data caching of several feature images and many more
 * @author Erik Rodner
@@ -15,290 +15,315 @@
 #include "core/image/MultiChannelImageT.h"
 #include "core/basics/FileMgt.h"
 
-using namespace NICE;
-
-namespace OBJREC {
+namespace OBJREC
+{
 
 /** data caching of several feature images and many more,
-    can be used in conjunction with Example 
+    can be used in conjunction with Example
     to share image data between different sliding windows within
     an image
     @see Example */
 class CachedExample
 {
 
-    protected:
-	/** resize image to this fixed width */
-	int newWidth;
-	/** resize image to this fixed height */
-	int newHeight;
-
-	/** original image width */
-	int oxsize;
-	/** original image height */
-	int oysize;
-
-	/** filename of image */
-	std::string imgfn;
-
-	/** array of double images */
-	MultiChannelImageT<double> *dchannels;
-
-	/** array of integer images */
-	MultiChannelImageT<int> *ichannels;
-
-	/** array of histogram images */
-	MultiChannelImageT<long> *lchannels;
-
-	/** maps for temporary files */
-	std::map<int, std::string> dtemps;
-	std::map<int, std::string> itemps;
-	std::map<int, std::string> ltemps;
-
-	/** read standard image data from file */
-	void readImageData ();
-	
-	/** read rgb image data from file */
-	void readImageDataRGB ();
-
-	/** calc grayvalue integral image */
-	void calcIntegralImage ();
-
-	/** array of histogram images */
-	SparseVector **svmap;
-	
-	/** sizes of histogram images */
-	int *svmap_xsize;
-	int *svmap_ysize;
-
-	bool hasColorInformation;
-
-    public:
-
-	/** whether one can obtain color information */
-	bool colorInformationAvailable() const;
-
-  	enum {
-	    L_INTEGRALIMAGE = 0,
-	    L_NUMCHANNELS
-	};
-
-	/** integer channel types */
-	enum {
-	    I_GRAYVALUES = 0,
-	    I_COLOR,
-	    I_EDGES,
-	    I_NUMCHANNELS
-	};
-
-	/** double value channels */
-	enum {
-	    D_EOH = 0,
-	    D_INTEGRALPRIOR,
-	    D_INTEGRALEOH,
-	    D_INTEGRALCOLOR,
-	    D_NUMCHANNELS
-	};
-
-	
-	/** sparse histogram channel types */
-	enum {
-	    SVTEXTON = 0,
-	    SVNUMCHANNELS
-	};
-
-	/** default init method */
-	void init ();
-
-	/** simple constructor 
-	    @param imgfn image filename
-	    @param newWidth resize raw image to this width
-	    @param newHeight resize raw image to this height
-	*/
-	CachedExample( const std::string & imgfn, int newWidth = -1, 
-					     int newHeight = -1 );
-	
-	/** constructor (disabled buffering)
-	    @param img gray-value image
-	*/
-	CachedExample( const NICE::Image & img );
-      
-	/** constructor (disabled buffering)
-	    @param img rgb image
-	    @param disableGrayConversion whether to provide gray values or not
-	*/
-	CachedExample( const NICE::ColorImage & img, bool disableGrayConversion = false );
-
-	/** simple destructor */
-	virtual ~CachedExample();
-
-	/**
-	 * get the NICE::Image Filename
-	 * @return NICE::Image Filename
-	 */
-	inline std::string getFilename();
-	
-	
-	/** get double image channel 
-	    @param channel channel type (choose from enum type)
-	    @param[out] xsize width of image
-	    @param[out] ysize height of image
-	    @return buffer to image data
-	*/
-	inline MultiChannelImageT<double> & getDChannel ( int channel ); 
-
-	/** get integer image channel 
-	    @param channel channel type (choose from enum type)
-	    @param[out] xsize width of image
-	    @param[out] ysize height of image
-	    @return buffer to image data
-	*/
-	inline MultiChannelImageT<int> & getIChannel ( int channel ); 
-
-	/** get long image channel 
-	    @param channel channel type (choose from enum type)
-	    @param[out] xsize width of image
-	    @param[out] ysize height of image
-	    @return buffer to image data
-	*/
-	inline MultiChannelImageT<long> & getLChannel ( int channel ); 
-
-	/** get histogram image
-	    @param svchannel channel type (choose from histogram channel enum)
-	    @param[out] xsize width of raw image
-	    @param[out] ysize height of raw image
-	    @param[out] tm_xsize width of histogram channel buffer
-	    @param[out] tm_ysize height of histogram channel buffer
-	    @remark buffer will be not copied !!
-	    @return pointer to histogram channel buffer
-	*/
-	SparseVector *getSVMap ( int svchannel, int & xsize, int & ysize, int & tm_xsize, int & tm_ysize ) const;
-
-	/** assign histogram channel buffer and compute integral image
-	    @param svchannel 
-	    @param _map pointer to histogram channel buffer
-	    @param xsize_s width of histogram channel buffer
-	    @param ysize_s height of histogram channel buffer
-	    @remark buffer will be not copied !!
-	*/
-	void buildIntegralSV ( int svchannel, SparseVector *_map, int xsize_s, int ysize_s );
-	
-    	/** assign histogram channel buffer
-	    @param svchannel 
-	    @param _map pointer to histogram channel buffer
-	    @param xsize_s width of histogram channel buffer
-	    @param ysize_s height of histogram channel buffer
-	    @remark buffer will be not copied !!
-	*/
-	void setSVMap ( int svchannel, SparseVector *_map, int xsize_s, int ysize_s );
-
-	/** get image sizes */
-	void getImageSize ( int & xsize, int & ysize ) const { xsize = oxsize; ysize = oysize; };
-
-	/** drop precached data: 
-		(1) this is only possible if an image filename is given 
-		(2) only data channels are deleted that can be reproduced by CachedExample itself
-	*/
-	void dropPreCached();
-
-	template<class ImgPixelValue>
-	void dropImages ( MultiChannelImageT<ImgPixelValue> *images, 
-			  std::map<int, std::string> & temps, 
-			  int numImages ); 
+  protected:
+    /** resize image to this fixed width */
+    int newWidth;
+    /** resize image to this fixed height */
+    int newHeight;
+
+    /** original image width */
+    int oxsize;
+    /** original image height */
+    int oysize;
+
+    /** filename of image */
+    std::string imgfn;
+
+    /** array of double images */
+    NICE::MultiChannelImageT<double> *dchannels;
+
+    /** array of integer images */
+    NICE::MultiChannelImageT<int> *ichannels;
+
+    /** array of histogram images */
+    NICE::MultiChannelImageT<long> *lchannels;
+
+    /** maps for temporary files */
+    std::map<int, std::string> dtemps;
+    std::map<int, std::string> itemps;
+    std::map<int, std::string> ltemps;
+
+    /** read standard image data from file */
+    void readImageData ();
+
+    /** read rgb image data from file */
+    void readImageDataRGB ();
+
+    /** calc grayvalue integral image */
+    void calcIntegralImage ();
+
+    /** array of histogram images */
+    NICE::SparseVector **svmap;
+
+    /** sizes of histogram images */
+    int *svmap_xsize;
+    int *svmap_ysize;
+
+    bool hasColorInformation;
+
+  public:
+
+    /** whether one can obtain color information */
+    bool colorInformationAvailable() const;
+
+    enum
+    {
+      L_INTEGRALIMAGE = 0,
+      L_NUMCHANNELS
+    };
+
+    /** integer channel types */
+    enum
+    {
+      I_GRAYVALUES = 0,
+      I_COLOR,
+      I_EDGES,
+      I_NUMCHANNELS
+    };
+
+    /** double value channels */
+    enum
+    {
+      D_EOH = 0,
+      D_INTEGRALPRIOR,
+      D_INTEGRALEOH,
+      D_INTEGRALCOLOR,
+      D_NUMCHANNELS
+    };
+
+
+    /** sparse histogram channel types */
+    enum
+    {
+      SVTEXTON = 0,
+      SVNUMCHANNELS
+    };
+
+    /** default init method */
+    void init ();
+
+    /** simple constructor
+        @param imgfn image filename
+        @param newWidth resize raw image to this width
+        @param newHeight resize raw image to this height
+    */
+    CachedExample ( const std::string & imgfn, int newWidth = -1,
+                    int newHeight = -1 );
+
+    /** constructor (disabled buffering)
+        @param img gray-value image
+    */
+    CachedExample ( const NICE::Image & img );
+
+    /** constructor (disabled buffering)
+        @param img rgb image
+        @param disableGrayConversion whether to provide gray values or not
+    */
+    CachedExample ( const NICE::ColorImage & img, bool disableGrayConversion = false );
+
+    /** simple destructor */
+    virtual ~CachedExample();
+
+    /**
+     * get the NICE::Image Filename
+     * @return NICE::Image Filename
+     */
+    inline std::string getFilename();
+
+
+    /** get double image channel
+        @param channel channel type (choose from enum type)
+        @param[out] xsize width of image
+        @param[out] ysize height of image
+        @return buffer to image data
+    */
+    inline NICE::MultiChannelImageT<double> & getDChannel ( int channel );
+
+    /** get integer image channel
+        @param channel channel type (choose from enum type)
+        @param[out] xsize width of image
+        @param[out] ysize height of image
+        @return buffer to image data
+    */
+    inline NICE::MultiChannelImageT<int> & getIChannel ( int channel );
+
+    /** get long image channel
+        @param channel channel type (choose from enum type)
+        @param[out] xsize width of image
+        @param[out] ysize height of image
+        @return buffer to image data
+    */
+    inline NICE::MultiChannelImageT<long> & getLChannel ( int channel );
+
+    /** get histogram image
+        @param svchannel channel type (choose from histogram channel enum)
+        @param[out] xsize width of raw image
+        @param[out] ysize height of raw image
+        @param[out] tm_xsize width of histogram channel buffer
+        @param[out] tm_ysize height of histogram channel buffer
+        @remark buffer will be not copied !!
+        @return pointer to histogram channel buffer
+    */
+    NICE::SparseVector *getSVMap ( int svchannel, int & xsize, int & ysize, int & tm_xsize, int & tm_ysize ) const;
+
+    /** assign histogram channel buffer and compute integral image
+        @param svchannel
+        @param _map pointer to histogram channel buffer
+        @param xsize_s width of histogram channel buffer
+        @param ysize_s height of histogram channel buffer
+        @remark buffer will be not copied !!
+    */
+    void buildIntegralSV ( int svchannel, NICE::SparseVector *_map, int xsize_s, int ysize_s );
+
+    /** assign histogram channel buffer
+    @param svchannel
+    @param _map pointer to histogram channel buffer
+    @param xsize_s width of histogram channel buffer
+    @param ysize_s height of histogram channel buffer
+    @remark buffer will be not copied !!
+    */
+    void setSVMap ( int svchannel, NICE::SparseVector *_map, int xsize_s, int ysize_s );
+
+    /** get image sizes */
+    void getImageSize ( int & xsize, int & ysize ) const
+    {
+      xsize = oxsize;
+      ysize = oysize;
+    };
+
+    /** drop precached data:
+     (1) this is only possible if an image filename is given
+     (2) only data channels are deleted that can be reproduced by CachedExample itself
+    */
+    void dropPreCached();
+
+    template<class ImgPixelValue>
+    void dropImages ( NICE::MultiChannelImageT<ImgPixelValue> *images,
+                      std::map<int, std::string> & temps,
+                      int numImages );
 };
 
 
 /********************** INLINE FUNCTIONS *****************************/
-inline MultiChannelImageT<double> & CachedExample::getDChannel ( int channel )
+inline NICE::MultiChannelImageT<double> & CachedExample::getDChannel ( int channel )
 {
-    assert ( (channel >= 0) && (channel < D_NUMCHANNELS) ); 
-
-    if ( dchannels[channel].data == NULL ) {
-	std::map<int, std::string>::const_iterator j = dtemps.find(channel);
-	if ( j == dtemps.end() ) {
-	    //fprintf (stderr, "MultiChannelImageT: unable to recover data channel %s (double %d)!\n", 
-	    //	imgfn.c_str(), channel);
-	} else {
-	    //fprintf (stderr, "MultiChannelImageT: restoring data from %s ", j->second.c_str() );
-	    dchannels[channel].restore ( j->second );
-	    //fprintf (stderr, "(%d x %d)\n", dchannels[channel].xsize, dchannels[channel].ysize );
-	}
+  assert ( ( channel >= 0 ) && ( channel < D_NUMCHANNELS ) );
+
+  if ( dchannels[channel].data == NULL )
+  {
+    std::map<int, std::string>::const_iterator j = dtemps.find ( channel );
+    if ( j == dtemps.end() )
+    {
+      //fprintf (stderr, "NICE::MultiChannelImageT: unable to recover data channel %s (double %d)!\n",
+      // imgfn.c_str(), channel);
+    }
+    else
+    {
+      //fprintf (stderr, "NICE::MultiChannelImageT: restoring data from %s ", j->second.c_str() );
+      dchannels[channel].restore ( j->second );
+      //fprintf (stderr, "(%d x %d)\n", dchannels[channel].xsize, dchannels[channel].ysize );
     }
+  }
 
-    return dchannels[channel];
+  return dchannels[channel];
 }
 
 inline std::string CachedExample::getFilename()
 {
-	return imgfn;
+  return imgfn;
 }
 
-inline MultiChannelImageT<int> & CachedExample::getIChannel ( int channel )
+inline NICE::MultiChannelImageT<int> & CachedExample::getIChannel ( int channel )
 {
-    assert ( (channel >= 0) && (channel < I_NUMCHANNELS) ); 
+  assert ( ( channel >= 0 ) && ( channel < I_NUMCHANNELS ) );
 
-    if ( (ichannels[channel].data == NULL) )
+  if ( ( ichannels[channel].data == NULL ) )
+  {
+    if ( ( imgfn != "" ) && ( channel == I_GRAYVALUES ) )
     {
-	if ( (imgfn != "") && (channel == I_GRAYVALUES) ) 
-	{
-	    readImageData();
-	} else if ( (imgfn != "") && (channel == I_COLOR) ) {
-	    readImageDataRGB();
-	    assert ( hasColorInformation );
-	} else {
-	    std::map<int, std::string>::const_iterator j = itemps.find(channel);
-	    if ( j == itemps.end() ) {
-		//fprintf (stderr, "MultiChannelImageT: unable to recover data channel (int %d)!\n", channel);
-		//exit(-1);
-	    } else {
-		//fprintf (stderr, "MultiChannelImageT: restoring data from %s\n", j->second.c_str() );
-		ichannels[channel].restore ( j->second );
-	    }
-	}
+      readImageData();
     }
+    else if ( ( imgfn != "" ) && ( channel == I_COLOR ) )
+    {
+      readImageDataRGB();
+      assert ( hasColorInformation );
+    }
+    else
+    {
+      std::map<int, std::string>::const_iterator j = itemps.find ( channel );
+      if ( j == itemps.end() )
+      {
+        //fprintf (stderr, "NICE::MultiChannelImageT: unable to recover data channel (int %d)!\n", channel);
+        //exit(-1);
+      }
+      else
+      {
+        //fprintf (stderr, "NICE::MultiChannelImageT: restoring data from %s\n", j->second.c_str() );
+        ichannels[channel].restore ( j->second );
+      }
+    }
+  }
 
-    return ichannels[channel];
+  return ichannels[channel];
 }
 
-inline MultiChannelImageT<long> & CachedExample::getLChannel ( int channel )
+inline NICE::MultiChannelImageT<long> & CachedExample::getLChannel ( int channel )
 {
-    assert ( (channel >= 0) && (channel < L_NUMCHANNELS) ); 
-
-    if ( lchannels[channel].data == NULL ) {
-	std::map<int, std::string>::const_iterator j = ltemps.find(channel);
-	if ( j == ltemps.end() ) {
-
-	    if ( channel == L_INTEGRALIMAGE ) {
-		calcIntegralImage();
-	    } else {
-		//fprintf (stderr, "MultiChannelImageT: unable to recover data channel (long %d)!\n", channel);
-		//exit(-1);
-	    }
-	} else {
-	    //fprintf (stderr, "MultiChannelImageT: restoring data from %s\n", j->second.c_str() );
-	    lchannels[channel].restore ( j->second );
-	}
+  assert ( ( channel >= 0 ) && ( channel < L_NUMCHANNELS ) );
+
+  if ( lchannels[channel].data == NULL )
+  {
+    std::map<int, std::string>::const_iterator j = ltemps.find ( channel );
+    if ( j == ltemps.end() )
+    {
+
+      if ( channel == L_INTEGRALIMAGE )
+      {
+        calcIntegralImage();
+      }
+      else
+      {
+        //fprintf (stderr, "NICE::MultiChannelImageT: unable to recover data channel (long %d)!\n", channel);
+        //exit(-1);
+      }
+    }
+    else
+    {
+      //fprintf (stderr, "NICE::MultiChannelImageT: restoring data from %s\n", j->second.c_str() );
+      lchannels[channel].restore ( j->second );
     }
+  }
 
-    return lchannels[channel];
+  return lchannels[channel];
 }
 
 template<class ImgPixelValue>
-void CachedExample::dropImages ( MultiChannelImageT<ImgPixelValue> *images, std::map<int, std::string> & temps, int numImages )
+void CachedExample::dropImages ( NICE::MultiChannelImageT<ImgPixelValue> *images, std::map<int, std::string> & temps, int numImages )
 {
-    for ( int i = 0 ; i < numImages; i++ )
+  for ( int i = 0 ; i < numImages; i++ )
+  {
+    std::map<int, std::string>::iterator j = temps.find ( i );
+    if ( j == temps.end() )
     {
-	std::map<int, std::string>::iterator j = temps.find(i);
-	if ( j == temps.end() )
-	{
-	    std::string tempfilename = FileMgt::createTempFile("tmp/cachedexample_%s");
-	    //fprintf (stderr, "CachedExample: dumping channel %d/%d to %s (%d x %d)\n", i, numImages, tempfilename.c_str(),
-	    //	images[i].xsize, images[i].ysize );
-	    images[i].store ( tempfilename );
-	    temps[i] = tempfilename;
-	}
-	images[i].freeData();
+      std::string tempfilename = NICE::FileMgt::createTempFile ( "tmp/cachedexample_%s" );
+      //fprintf (stderr, "CachedExample: dumping channel %d/%d to %s (%d x %d)\n", i, numImages, tempfilename.c_str(),
+      // images[i].xsize, images[i].ysize );
+      images[i].store ( tempfilename );
+      temps[i] = tempfilename;
     }
+    images[i].freeData();
+  }
 
 }
 

+ 73 - 62
cbaselib/ImageInfo.h

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file ImageInfo.h
 * @brief localization info + image filename + ?
 * @author Erik Rodner
@@ -10,7 +10,7 @@
 #include "core/image/ImageT.h"
 #include "core/vector/VectorT.h"
 #include "core/vector/MatrixT.h"
- 
+
 #include "vislearning/cbaselib/Polygon.h"
 #include "vislearning/cbaselib/BoundingBox.h"
 #include "vislearning/cbaselib/CategoryInfo.h"
@@ -25,71 +25,82 @@ class QDomElement;
 
 #endif //NICE_USELIB_QT4_XML
 
-namespace OBJREC {
+namespace OBJREC
+{
 
 /** localization info + image filename + ? */
 class ImageInfo
 {
 
-    protected:
-	std::string imagefn;
-	LocalizationResult *lr;
-	bool localization_info;
-
-	#ifdef NICE_USELIB_QT4_XML
-	
-	Polygon	polyFromData(QString *aPolyData);
-	BoundingBox BBoxFromData(QString *aBBoxData);
-	void loadLegendFromElement(QDomElement *anElement);
-	bool loadCategoryInfo(QDomElement *anElement);
-	ImageT< unsigned int >	imageTFromData(
-		const int &aWidth,
-		const int &aHeight,
-		QString *aPureData
-	);
-
-	#endif //NICE_USELIB_QT4_XML
-
-    public:
-  
-	/** simple constructor */
-	ImageInfo( const std::string & _imagefn, LocalizationResult *_lr ) : 
-	    imagefn(_imagefn), lr(_lr), localization_info(true) {};
-	
-	ImageInfo() {};
-      
-	ImageInfo( const std::string & _imagefn ) : 
-	    imagefn(_imagefn), lr(NULL), localization_info(false) {};
-
-	/** simple destructor */
-	virtual ~ImageInfo();
-
-	const std::string & img () const { return imagefn; };
-	const LocalizationResult *localization () const { assert(localization_info); return lr; };
-	bool hasLocalizationInfo () const { return localization_info; };
-	
-	bool loadImageInfo(const std::string &aFilename);
-	
-	const std::list< CategoryInfo > * labels() const;
-	const std::list< BoundingBox > * bboxes() const;
-	const std::list< Polygon > * polys() const;
-	ImageT< unsigned int > labeledImage() const;
-	std::string tags() const;
-	std::string imagePath() const;
-	std::string imageDescription() const;
-	std::string segmentedImagePath() const;
-
-    private:
-	std::list< CategoryInfo > labels_;
-	std::list< BoundingBox > bboxes_;
-	std::list< Polygon > polys_;
-	ImageT< unsigned int > labeled_image_;
-	//std::list< std::string > tags_;
-	std::string tags_;
-	std::string image_path_;
-	std::string image_description_;
-	std::string segmented_image_path_;
-	
+  protected:
+    std::string imagefn;
+    LocalizationResult *lr;
+    bool localization_info;
+
+#ifdef NICE_USELIB_QT4_XML
+
+    Polygon polyFromData ( QString *aPolyData );
+    BoundingBox BBoxFromData ( QString *aBBoxData );
+    void loadLegendFromElement ( QDomElement *anElement );
+    bool loadCategoryInfo ( QDomElement *anElement );
+    NICE::ImageT< unsigned int > imageTFromData (
+      const int &aWidth,
+      const int &aHeight,
+      QString *aPureData
+    );
+
+#endif //NICE_USELIB_QT4_XML
+
+  public:
+
+    /** simple constructor */
+    ImageInfo ( const std::string & _imagefn, LocalizationResult *_lr ) :
+        imagefn ( _imagefn ), lr ( _lr ), localization_info ( true ) {};
+
+    ImageInfo() {};
+
+    ImageInfo ( const std::string & _imagefn ) :
+        imagefn ( _imagefn ), lr ( NULL ), localization_info ( false ) {};
+
+    /** simple destructor */
+    virtual ~ImageInfo();
+
+    const std::string & img () const
+    {
+      return imagefn;
+    };
+    const LocalizationResult *localization () const
+    {
+      assert ( localization_info );
+      return lr;
+    };
+    bool hasLocalizationInfo () const
+    {
+      return localization_info;
+    };
+
+    bool loadImageInfo ( const std::string &aFilename );
+
+    const std::list< CategoryInfo > * labels() const;
+    const std::list< BoundingBox > * bboxes() const;
+    const std::list< Polygon > * polys() const;
+    NICE::ImageT< unsigned int > labeledImage() const;
+    std::string tags() const;
+    std::string imagePath() const;
+    std::string imageDescription() const;
+    std::string segmentedImagePath() const;
+
+  private:
+    std::list< CategoryInfo > labels_;
+    std::list< BoundingBox > bboxes_;
+    std::list< Polygon > polys_;
+    NICE::ImageT< unsigned int > labeled_image_;
+    //std::list< std::string > tags_;
+    std::string tags_;
+    std::string image_path_;
+    std::string image_description_;
+    std::string segmented_image_path_;
+
 };
 
 

+ 20 - 20
cbaselib/Polygon.h

@@ -11,31 +11,31 @@
 #include "core/image/CoordT.h"
 #include <list>
 
-using namespace NICE;
 
-typedef std::list< CoordT< int > > PointsList;
+typedef std::list< NICE::CoordT< int > > PointsList;
 
-namespace OBJREC {
+namespace OBJREC
+{
 
 //! \brief Contains category ID and point list of the polygon
 class Polygon
 {
-public:
-	Polygon();
-	Polygon(const Polygon &copy);
-	~Polygon();
-	
-	void push(const CoordT< int > &aPoint);
-	void push(const int &x, const int &y);
-	void setID(const int &anID);
-	
-	const PointsList * points() const;
-	CoordT< int > pop();
-	int id() const;
-	
-private:
-	PointsList points_;
-	int id_;
+  public:
+    Polygon();
+    Polygon ( const Polygon &copy );
+    ~Polygon();
+
+    void push ( const NICE::CoordT< int > &aPoint );
+    void push ( const int &x, const int &y );
+    void setID ( const int &anID );
+
+    const PointsList * points() const;
+    NICE::CoordT< int > pop();
+    int id() const;
+
+  private:
+    PointsList points_;
+    int id_;
 };
 
 } //namespace
@@ -43,5 +43,5 @@ private:
 #endif /* __POLYGON_H__ */
 
 /*
- * 
+ *
  */

+ 28 - 27
cbaselib/progs/statisticsLabeledSetVector.cpp

@@ -6,47 +6,48 @@
 
 using namespace std;
 using namespace OBJREC;
+using namespace NICE;
 
 int main ( int argc, char **argv )
 {
 
-    Config conf ( argc, argv );
+  Config conf ( argc, argv );
 
-    string setfn = conf.gS("main", "set", "train.vec" );
-    int format = conf.gI("main", "format", 2 );
+  string setfn = conf.gS ( "main", "set", "train.vec" );
+  int format = conf.gI ( "main", "format", 2 );
 
-    LabeledSetVector set;
+  LabeledSetVector set;
 
-    set.read ( setfn, format );
+  set.read ( setfn, format );
 
-    set.printInformation();
+  set.printInformation();
 
-    double maximum_value = - numeric_limits<double>::max();
-    double minimum_value = numeric_limits<double>::max();
-    double maximum_norm = 0;
-    double minimum_norm = numeric_limits<double>::max();
+  double maximum_value = - numeric_limits<double>::max();
+  double minimum_value = numeric_limits<double>::max();
+  double maximum_norm = 0;
+  double minimum_norm = numeric_limits<double>::max();
 
-    LOOP_ALL(set)
-    {
-	EACH(classno, x);
+  LOOP_ALL ( set )
+  {
+    EACH ( classno, x );
 
-	if ( x.Max() > maximum_value ) 
-	    maximum_value = x.Max();
+    if ( x.Max() > maximum_value )
+      maximum_value = x.Max();
 
-	if ( x.Min() < minimum_value ) 
-	    minimum_value = x.Min();
+    if ( x.Min() < minimum_value )
+      minimum_value = x.Min();
 
-	if ( x.normL2() > maximum_norm )
-	    maximum_norm = x.normL2();
+    if ( x.normL2() > maximum_norm )
+      maximum_norm = x.normL2();
 
-	if ( x.normL2() < minimum_norm )
-	    minimum_norm = x.normL2();
+    if ( x.normL2() < minimum_norm )
+      minimum_norm = x.normL2();
 
-    }
+  }
 
-    fprintf (stderr, "min value: %f\n", minimum_value );
-    fprintf (stderr, "max value: %f\n", maximum_value );
-    fprintf (stderr, "min L2-norm: %f\n", minimum_norm );
-    fprintf (stderr, "max L2-norm: %f\n", maximum_norm );
-    fprintf (stderr, "dimension: %d\n", set.dimension() );
+  fprintf ( stderr, "min value: %f\n", minimum_value );
+  fprintf ( stderr, "max value: %f\n", maximum_value );
+  fprintf ( stderr, "min L2-norm: %f\n", minimum_norm );
+  fprintf ( stderr, "max L2-norm: %f\n", maximum_norm );
+  fprintf ( stderr, "dimension: %d\n", set.dimension() );
 }

+ 58 - 52
classifier/classifierbase/KernelClassifier.h

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file KernelClassifier.h
 * @brief classifier interface for kernel based methods
 * @author Erik Rodner
@@ -16,78 +16,84 @@
 #include "vislearning/cbaselib/LabeledSet.h"
 #include "vislearning/classifier/classifierbase/VecClassifier.h"
 
-namespace OBJREC {
-  
+namespace OBJREC
+{
+
 /** classifier interface for kernel based methods */
 class KernelClassifier : public VecClassifier
 {
-	public:
-		enum {
-			KERNELCLASSIFIER_NORMALIZATION_EUCLIDEAN = 0,
-			KERNELCLASSIFIER_NORMALIZATION_NONE
-		};
+  public:
+    enum
+    {
+      KERNELCLASSIFIER_NORMALIZATION_EUCLIDEAN = 0,
+      KERNELCLASSIFIER_NORMALIZATION_NONE
+    };
+
+  protected:
+
+    /** This variable might be NULL, if you do not specify a kernel function */
+    Kernel *kernelFunction;
+
+    /** This is the training set, if you specify a kernel function */
+    NICE::VVector vecSet;
+
+    /** These are the labels of the training set, if you specify a kernel function */
+    NICE::Vector vecSetLabels;
 
-    protected:
+    /** Maybe you want to normalize feature vectors before training */
+    int normalizationType;
 
-		/** This variable might be NULL, if you do not specify a kernel function */
-		Kernel *kernelFunction;
-		
-		/** This is the training set, if you specify a kernel function */
-		NICE::VVector vecSet;
+    /** stored config to initialize KernelData with noiseSigma, cholesky method etc. */
+    NICE::Config conf;
 
-		/** These are the labels of the training set, if you specify a kernel function */
-		NICE::Vector vecSetLabels;
+  public:
+    /** simple constructor */
+    KernelClassifier() {};
 
-		/** Maybe you want to normalize feature vectors before training */
-		int normalizationType;
+    /** specify a kernel function which works on vectors and a normalization method ( use the enum defined in KernelClassifier ) */
+    KernelClassifier ( const NICE::Config *conf, Kernel *kernelFunction = NULL, int normalizationType = KERNELCLASSIFIER_NORMALIZATION_EUCLIDEAN );
 
-		/** stored config to initialize KernelData with noiseSigma, cholesky method etc. */
-		NICE::Config conf;
+    /** copy constructor which you should also call in subclasses */
+    KernelClassifier ( const KernelClassifier & src );
 
-    public:
-  		/** simple constructor */
-		KernelClassifier(){};
-	    
-		/** specify a kernel function which works on vectors and a normalization method ( use the enum defined in KernelClassifier ) */
-		KernelClassifier( const NICE::Config *conf, Kernel *kernelFunction = NULL, int normalizationType = KERNELCLASSIFIER_NORMALIZATION_EUCLIDEAN );
+    /** simple destructor */
+    virtual ~KernelClassifier();
 
-		/** copy constructor which you should also call in subclasses */
-		KernelClassifier ( const KernelClassifier & src );
 
-		/** simple destructor */
-		virtual ~KernelClassifier();
+    // interface function
 
+    /** teach the classifier with a kernel matrix and the corresponding class labels @param y ! */
+    virtual void teach ( KernelData *kernelData, const NICE::Vector & y ) = 0;
 
-		// interface function
+    /** classify an example by using its kernel values with the training set,
+     be careful with the order in @param kernelVector */
+    virtual ClassificationResult classifyKernel ( const NICE::Vector & kernelVector, double kernelSelf ) const = 0;
 
-		/** teach the classifier with a kernel matrix and the corresponding class labels @param y ! */
-		virtual void teach ( KernelData *kernelData, const NICE::Vector & y ) = 0;
 
-		/** classify an example by using its kernel values with the training set,
-			be careful with the order in @param kernelVector */
-		virtual ClassificationResult classifyKernel ( const NICE::Vector & kernelVector, double kernelSelf ) const = 0;
+    // functions to build an interface to VecClassifier
 
+    /** classify using simple vector, this works only if you specify a kernel function */
+    ClassificationResult classify ( const NICE::Vector & x ) const;
 
-		// functions to build an interface to VecClassifier
+    /** teach classifier with a labeled set of feature vectors, this works only if you specify a kernel function */
+    virtual void teach ( const LabeledSetVector & teachSet );
 
-		/** classify using simple vector, this works only if you specify a kernel function */
-		ClassificationResult classify ( const NICE::Vector & x ) const;
+    /** calculate classifier stuff as the last training step, pretty useless, deprecated */
+    void finishTeaching() {};
 
-		/** teach classifier with a labeled set of feature vectors, this works only if you specify a kernel function */
-		virtual void teach ( const LabeledSetVector & teachSet );
-		
-		/** calculate classifier stuff as the last training step, pretty useless, deprecated */
-		void finishTeaching() {};
+    /** clone this object */
+    KernelClassifier *clone ( void ) const
+    {
+      fthrow ( NICE::Exception, "clone() not yet implemented." );
+    }
 
-		/** clone this object */
-		KernelClassifier *clone(void) const {
-			fthrow(Exception, "clone() not yet implemented.");
-		}
+    Kernel *getKernelFunction () const
+    {
+      return kernelFunction;
+    };
 
-		Kernel *getKernelFunction () const { return kernelFunction; }; 
-		
-		virtual void restore(std::istream&, int);
-		virtual void store(std::ostream&, int) const;
+    virtual void restore ( std::istream&, int );
+    virtual void store ( std::ostream&, int ) const;
 };
 
 }

+ 31 - 24
classifier/classifierbase/VecClassifier.h

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file VecClassifier.h
 * @brief Simple classification interface
 * @author Erik Rodner
@@ -14,41 +14,48 @@
 #include "vislearning/cbaselib/LabeledSet.h"
 #include "vislearning/cbaselib/ClassificationResult.h"
 
-#define ROADWORKS fthrow(Exception, "clone(): not yet implemented!");
+#define ROADWORKS fthrow(NICE::Exception, "clone(): not yet implemented!");
 
-namespace OBJREC {
+namespace OBJREC
+{
 
 /** Simple classification interface */
 class VecClassifier : public NICE::Persistent
 {
-    protected:
-		int maxClassNo;
+  protected:
+    int maxClassNo;
+
+  public:
+
+    VecClassifier()
+    {
+      maxClassNo = 0;
+    };
+
+    /** simple constructor */
+    VecClassifier ( const NICE::Config *conf );
 
-    public:
- 
-		VecClassifier() { maxClassNo = 0; };
+    /** simple destructor */
+    virtual ~VecClassifier();
 
-		/** simple constructor */
-		VecClassifier( const NICE::Config *conf );
+    virtual void setMaxClassNo ( int maxClassNo );
 
-		/** simple destructor */
-		virtual ~VecClassifier();
+    virtual int getMaxClassNo () const;
 
-		virtual void setMaxClassNo ( int maxClassNo );
-		
-		virtual int getMaxClassNo () const;
+    /** classify using simple vector */
+    virtual ClassificationResult classify ( const NICE::Vector & x ) const = 0;
 
-		/** classify using simple vector */
-		virtual ClassificationResult classify ( const NICE::Vector & x ) const = 0;
+    /** teach classifier with a labeled set of feature vectors */
+    virtual void teach ( const LabeledSetVector & teachSet ) = 0;
 
-		/** teach classifier with a labeled set of feature vectors */
-		virtual void teach ( const LabeledSetVector & teachSet ) = 0;
-		
-		/** calculate classifier stuff as the last training step */
-		virtual void finishTeaching() = 0;
+    /** calculate classifier stuff as the last training step */
+    virtual void finishTeaching() = 0;
 
-		/** clone this object */
-		virtual VecClassifier *clone(void) const { ROADWORKS; };
+    /** clone this object */
+    virtual VecClassifier *clone ( void ) const
+    {
+      ROADWORKS;
+    };
 };
 
 #undef ROADWORKS

+ 94 - 91
classifier/fpclassifier/boosting/FPCBoosting.h

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file FPCBoosting.h
 * @brief implementation of boosting algorithms
 * @author Erik Rodner
@@ -16,102 +16,105 @@
 #include "vislearning/cbaselib/FeaturePool.h"
 #include "core/basics/triplet.h"
 
-
-
-namespace OBJREC {
+namespace OBJREC
+{
 
 /** @brief a strong classifier is a collection of weighted classifiers: \f$a \cdot h_t(\mathbf{x}) + b\f$ */
-class StrongClassifier : public std::vector< triplet<double, double, FeaturePoolClassifier *> >
-{};
+class StrongClassifier : public std::vector< NICE::triplet<double, double, FeaturePoolClassifier *> >
+  {};
 
 /** @brief implementation of boosting algorithms */
 class FPCBoosting : public FeaturePoolClassifier
 {
-    protected:
-	const NICE::Config *conf;
-
-	/** @brief normalize weights for each class independently */
-	bool classwise_normalization;
-
-	/** @brief boosting method ( select one value from the enum-type ) */
-	int boosting_method;
-
-	/** @brief class no corresponding to the positive class */
-	int positive_class;
-
-	/** @brief maximum number of rounds */
-	int maxRounds;
-
-	/** @brief memory efficiency by caching and storing of features on the hard disc */
-	bool memory_efficient;
-
-	/** @brief prototype of a weak classifier
-	    
-	    The generation of a new weak classifier is done by the clone method
-	    of this object.
-	*/
-	FeaturePoolClassifier *weakClassifier;
-
-	/** @brief final strong classifier */
-	StrongClassifier strongClassifier;
-
-	/** @brief perform boosting and build strongClassifier 
-	    @param featureStorage pre calculated features
-	    @param fp pool of features
-	    @param examples training examples */
-	void boosting ( const FeatureStorage & featureStorage,
-			FeaturePool & fp,
-			Examples & examples );
-
-	/** @brief normalize weights of examples
-	    @param examples training examples
-	*/
-	void normalizeWeights ( Examples & examples ) const;
-
-    public:
-	
-	enum {
-		BOOSTINGMETHOD_ADABOOST = 0,
-		BOOSTINGMETHOD_REAL_ADABOOST,
-		BOOSTINGMETHOD_GENTLEBOOST
-	};
-
-	/** @brief for cloning only */
-	FPCBoosting() {};
-
-	/** @brief constructor for training */
-	FPCBoosting( const NICE::Config *conf, 
-		  // refactor-nice.pl: check this substitution
-		  // old: string section = "Boost" );
-		  std::string section = "Boost" );
-    
-	/** @brief simple destructor */
-	virtual ~FPCBoosting();
-
-	/** @brief classify an unseen example */
-	ClassificationResult classify ( Example & pce );
-	
-	/** @brief train this classifier 
-	    @param fp pool of features
-	    @param examples training examples
-	*/
-	virtual void train ( FeaturePool & fp,
-		     Examples & examples );
-
-	/** @{ methods for persistency */
-	void restore (std::istream & is, int format = 0);
-	void store (std::ostream & os, int format = 0) const;
-	void clear ();
-	/** @} */
-
-	/** @brief creates a copy of this object */
-	FeaturePoolClassifier *clone () const;
-
-	/** @brief direct access to the classifier parameters */
-	StrongClassifier & getStrongClassifier () { return strongClassifier; };
-
-	/** @brief sets the maximum number of rounds */
-	void setComplexity ( int size );
+  protected:
+    const NICE::Config *conf;
+
+    /** @brief normalize weights for each class independently */
+    bool classwise_normalization;
+
+    /** @brief boosting method ( select one value from the enum-type ) */
+    int boosting_method;
+
+    /** @brief class no corresponding to the positive class */
+    int positive_class;
+
+    /** @brief maximum number of rounds */
+    int maxRounds;
+
+    /** @brief memory efficiency by caching and storing of features on the hard disc */
+    bool memory_efficient;
+
+    /** @brief prototype of a weak classifier
+
+        The generation of a new weak classifier is done by the clone method
+        of this object.
+    */
+    FeaturePoolClassifier *weakClassifier;
+
+    /** @brief final strong classifier */
+    StrongClassifier strongClassifier;
+
+    /** @brief perform boosting and build strongClassifier
+        @param featureStorage pre calculated features
+        @param fp pool of features
+        @param examples training examples */
+    void boosting ( const FeatureStorage & featureStorage,
+                    FeaturePool & fp,
+                    Examples & examples );
+
+    /** @brief normalize weights of examples
+        @param examples training examples
+    */
+    void normalizeWeights ( Examples & examples ) const;
+
+  public:
+
+    enum
+    {
+      BOOSTINGMETHOD_ADABOOST = 0,
+      BOOSTINGMETHOD_REAL_ADABOOST,
+      BOOSTINGMETHOD_GENTLEBOOST
+    };
+
+    /** @brief for cloning only */
+    FPCBoosting() {};
+
+    /** @brief constructor for training */
+    FPCBoosting ( const NICE::Config *conf,
+                  // refactor-nice.pl: check this substitution
+                  // old: string section = "Boost" );
+                  std::string section = "Boost" );
+
+    /** @brief simple destructor */
+    virtual ~FPCBoosting();
+
+    /** @brief classify an unseen example */
+    ClassificationResult classify ( Example & pce );
+
+    /** @brief train this classifier
+        @param fp pool of features
+        @param examples training examples
+    */
+    virtual void train ( FeaturePool & fp,
+                         Examples & examples );
+
+    /** @{ methods for persistency */
+    void restore ( std::istream & is, int format = 0 );
+    void store ( std::ostream & os, int format = 0 ) const;
+    void clear ();
+    /** @} */
+
+    /** @brief creates a copy of this object */
+    FeaturePoolClassifier *clone () const;
+
+    /** @brief direct access to the classifier parameters */
+    StrongClassifier & getStrongClassifier ()
+    {
+      return strongClassifier;
+    };
+
+    /** @brief sets the maximum number of rounds */
+    void setComplexity ( int size );
 };
 
 

+ 68 - 67
classifier/fpclassifier/logisticregression/FPCSMLR.h

@@ -1,4 +1,4 @@
-/** 
+/**
  * @file FPCSMLR.h
  * @brief implementation of Sparse Multinomial Logistic Regression (SMLR) Classififier, it uses a SLR for each class and combines the results
  * @author Björn Fröhlich
@@ -18,75 +18,76 @@
 #include "vislearning/cbaselib/FeaturePool.h"
 #include "core/algebra/GMSparseVectorMatrix.h"
 
-namespace OBJREC {
+namespace OBJREC
+{
 
 class FPCSMLR : public FeaturePoolClassifier
 {
-    protected:
-	//! the configuration file
-	const NICE::Config *conf;
-
-	//! section in the configfile
-	std::string confsection;
-	
-	//! the featurepool
-	FeaturePool fp;
-	
-	//! the one vs all sparse logistic classifiers
-	std::vector<SLR> classifiers;
-	
-	//! just use the features from pictures, which the class contains
-	bool inpic;
-		
-    public:
-	/**
-	 * standard constructor
-	 * @param conf configfile
-	 * @param section section name in configfile for classifier
-	 */
-	FPCSMLR( const NICE::Config *conf, std::string section="SMLR");
-      
-	
-	/**
-	 * simple constructor -> does nothing
-	 */
-	FPCSMLR ();
-
-	/**
-	 * simple destructor
-	 */
-	~FPCSMLR();
-
-	/**
-	 * main classification function
-	 * @param pce input feature
-	 * @return a classification result
-	 */
-	ClassificationResult classify ( Example & pce );
-
-	/**
-	 * start training
-	 * @param fp a featurepool (how to handle which features...)
-	 * @param examples input features
-	 */
-	void train ( FeaturePool & _fp, Examples & examples );
-
-	/**
-	 * clone this object
-	 * @return a copy of this object
-	 */
-	FeaturePoolClassifier *clone () const;
-
-	/**
-	 * set complexity for the next training process e.g. number of weak classifiers
-	 * @param size new complexity
-	 */
-	void setComplexity ( int size );
-
-	/** IO functions */
-	void restore (std::istream & is, int format = 0);
-	void store (std::ostream & os, int format = 0) const;
-	void clear ();
+  protected:
+    //! the configuration file
+    const NICE::Config *conf;
+
+    //! section in the configfile
+    std::string confsection;
+
+    //! the featurepool
+    FeaturePool fp;
+
+    //! the one vs all sparse logistic classifiers
+    std::vector<SLR> classifiers;
+
+    //! just use the features from pictures, which the class contains
+    bool inpic;
+
+  public:
+    /**
+     * standard constructor
+     * @param conf configfile
+     * @param section section name in configfile for classifier
+     */
+    FPCSMLR ( const NICE::Config *conf, std::string section="SMLR" );
+
+
+    /**
+     * simple constructor -> does nothing
+     */
+    FPCSMLR ();
+
+    /**
+     * simple destructor
+     */
+    ~FPCSMLR();
+
+    /**
+     * main classification function
+     * @param pce input feature
+     * @return a classification result
+     */
+    ClassificationResult classify ( Example & pce );
+
+    /**
+     * start training
+     * @param fp a featurepool (how to handle which features...)
+     * @param examples input features
+     */
+    void train ( FeaturePool & _fp, Examples & examples );
+
+    /**
+     * clone this object
+     * @return a copy of this object
+     */
+    FeaturePoolClassifier *clone () const;
+
+    /**
+     * set complexity for the next training process e.g. number of weak classifiers
+     * @param size new complexity
+     */
+    void setComplexity ( int size );
+
+    /** IO functions */
+    void restore ( std::istream & is, int format = 0 );
+    void store ( std::ostream & os, int format = 0 ) const;
+    void clear ();
 };
 
 } // namespace

+ 1 - 1
classifier/fpclassifier/logisticregression/SLR.h

@@ -29,7 +29,7 @@ class SLR : public NICE::Persistent
     std::string confsection;
 
     //! weight vectors
-    SparseVector weight;
+    NICE::SparseVector weight;
 
     //! the featurepool
     FeaturePool fp;

+ 42 - 26
classifier/fpclassifier/randomforest/FPCDecisionTree.h

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file FPCDecisionTree.h
 * @brief simple decision tree classifier
 * @author Erik Rodner
@@ -20,38 +20,54 @@
 #include "DecisionTree.h"
 
 #undef ROADWORKS
-#define ROADWORKS fthrow( Exception, "Persistent interface not yet implemented.");
+#define ROADWORKS fthrow( NICE::Exception, "Persistent interface not yet implemented.");
 
 
-namespace OBJREC {
+namespace OBJREC
+{
 
 /** simple decision tree classifier */
 class FPCDecisionTree : public FeaturePoolClassifier
 {
 
-    protected:
-		const NICE::Config *conf;
-		DecisionTree *dt;
-		DecisionTreeBuilder *builder;
-
-    public:
-  
-		/** simple constructor */
-		FPCDecisionTree( const NICE::Config *conf, std::string section );
-		  
-		/** simple destructor */
-		virtual ~FPCDecisionTree();
-		 
-		virtual ClassificationResult classify ( Example & pce );
-
-		virtual void train ( FeaturePool & fp, Examples & examples );
-
-		DecisionTree & getTree () { return *dt; };
-
-		void restore (std::istream & is, int format = 0) { ROADWORKS };
-		void store (std::ostream & os, int format = 0) const { ROADWORKS };
-		void clear () { ROADWORKS };
-		FeaturePoolClassifier *clone () const { ROADWORKS };
+  protected:
+    const NICE::Config *conf;
+    DecisionTree *dt;
+    DecisionTreeBuilder *builder;
+
+  public:
+
+    /** simple constructor */
+    FPCDecisionTree ( const NICE::Config *conf, std::string section );
+
+    /** simple destructor */
+    virtual ~FPCDecisionTree();
+
+    virtual ClassificationResult classify ( Example & pce );
+
+    virtual void train ( FeaturePool & fp, Examples & examples );
+
+    DecisionTree & getTree ()
+    {
+      return *dt;
+    };
+
+    void restore ( std::istream & is, int format = 0 )
+    {
+      ROADWORKS
+    };
+    void store ( std::ostream & os, int format = 0 ) const
+    {
+      ROADWORKS
+    };
+    void clear ()
+    {
+      ROADWORKS
+    };
+    FeaturePoolClassifier *clone () const
+    {
+      ROADWORKS
+    };
 
 
 

+ 118 - 108
classifier/fpclassifier/randomforest/FPCRandomForests.h

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file FPCRandomForests.h
 * @brief implementation of random set forests
 * @author Erik Rodner
@@ -22,117 +22,127 @@
 #include "DecisionTreeBuilder.h"
 
 
-namespace OBJREC {
+namespace OBJREC
+{
 
 /** implementation of random set forests */
 class FPCRandomForests : public FeaturePoolClassifier
 {
-    protected:
-		/** vector containing all decision trees */
-		std::vector<DecisionTree *> forest;	
-		
-		/** number of trees which will be generated in the
-		    during training */
-		int number_of_trees;
-
-		/** fraction of features used for each tree */
-		double features_per_tree;
-
-		/** fraction of training examples used for each tree */
-		double samples_per_tree;
-
-		/** use an equal number of training examples of each class
-		    to build a single tree */
-		bool use_simple_balancing;
-
-		/** weight examples according to a priori class probabilities
-		    as estimated using the distribution contained in the training data */
-		bool weight_examples;
-
-		/** if >0 then prune the trees using pruneTreeEntropy */
-		double minimum_entropy;
-
-		/** clear all examples after building a tree, this deletes
-		    all cached images contained in CachedExample etc. */
-		bool memory_efficient;
-
-		/** stored config to initialize a tree */
-		const NICE::Config *conf;
-
-		/** config section containing important config values */
-		std::string confsection;
-
-		/** pointer to the tree builder method */
-		DecisionTreeBuilder *builder;
-
-		/** out-of-bag statistics */
-		bool enableOutOfBagEstimates;
-		std::vector<std::pair<double, int> > oobResults;
-
-		/** classify using only a subset of all trees */
-		ClassificationResult classify ( Example & pce,
-							const std::vector<int> & outofbagtrees );
-
-		/** calculate out-of-bag statistics */
-		void calcOutOfBagEstimates ( std::vector< std::vector<int> > & outofbagtrees, 
-						 Examples & examples );
-		
-		/** save example selection per tree */
-		std::vector<std::vector<int> > exselection;
-
-    public:
-  
-		/** initialize the classifier */
-		FPCRandomForests( const NICE::Config *conf, 
-				  std::string section );
-		  
-		/** do nothing */
-		FPCRandomForests ();
-
-		/** simple destructor */
-		virtual ~FPCRandomForests();
-
-		/** main classification function */
-		ClassificationResult classify ( Example & pce );
-		int classify_optimize ( Example & pce );
-
-		/** get all leaf nodes for an given example (or inner nodes if depth is set to the level) */
-		void getLeafNodes ( Example & pce,
-					std::vector<DecisionNode *> & leafNodes,
-					int depth = 100000 );
-		/** get all leaf nodes (or inner nodes if depth is set to the level) */
-		void getAllLeafNodes ( std::vector<DecisionNode *> & leafNodes);
-		
-		/** perform training using a given feature pool and some training data */
-		virtual void train ( FeaturePool & fp,
-				 Examples & examples );
-
-		/** enumerate all nodes within the trees */
-		void indexDescendants ( std::map<DecisionNode *, std::pair<long, int> > & index ) const;
-
-		/** reset all counters in all nodes contained in the forest */
-		void resetCounters ();
-
-		/** direct access to all trees */
-		const std::vector<DecisionTree *> & getForest () const { return forest; };
-
-		/** direct write access to all trees */
-		std::vector<DecisionTree *> & getForestNonConst () { return forest; };
-
-		/** clone this object */
-		FeaturePoolClassifier *clone () const;
-		
-		/** get out of bag estimates */
-		std::vector<std::pair<double, int> > & getOutOfBagResults () { return oobResults; };
-
-		/** set the number of trees */
-		void setComplexity ( int size );
-
-		/** IO functions */
-		void restore (std::istream & is, int format = 0);
-		void store (std::ostream & os, int format = 0) const;
-		void clear ();
-	
+  protected:
+    /** vector containing all decision trees */
+    std::vector<DecisionTree *> forest;
+
+    /** number of trees which will be generated in the
+        during training */
+    int number_of_trees;
+
+    /** fraction of features used for each tree */
+    double features_per_tree;
+
+    /** fraction of training examples used for each tree */
+    double samples_per_tree;
+
+    /** use an equal number of training examples of each class
+        to build a single tree */
+    bool use_simple_balancing;
+
+    /** weight examples according to a priori class probabilities
+        as estimated using the distribution contained in the training data */
+    bool weight_examples;
+
+    /** if >0 then prune the trees using pruneTreeEntropy */
+    double minimum_entropy;
+
+    /** clear all examples after building a tree, this deletes
+        all cached images contained in CachedExample etc. */
+    bool memory_efficient;
+
+    /** stored config to initialize a tree */
+    const NICE::Config *conf;
+
+    /** config section containing important config values */
+    std::string confsection;
+
+    /** pointer to the tree builder method */
+    DecisionTreeBuilder *builder;
+
+    /** out-of-bag statistics */
+    bool enableOutOfBagEstimates;
+    std::vector<std::pair<double, int> > oobResults;
+
+    /** classify using only a subset of all trees */
+    ClassificationResult classify ( Example & pce,
+                                    const std::vector<int> & outofbagtrees );
+
+    /** calculate out-of-bag statistics */
+    void calcOutOfBagEstimates ( std::vector< std::vector<int> > & outofbagtrees,
+                                 Examples & examples );
+
+    /** save example selection per tree */
+    std::vector<std::vector<int> > exselection;
+
+  public:
+
+    /** initialize the classifier */
+    FPCRandomForests ( const NICE::Config *conf,
+                       std::string section );
+
+    /** do nothing */
+    FPCRandomForests ();
+
+    /** simple destructor */
+    virtual ~FPCRandomForests();
+
+    /** main classification function */
+    ClassificationResult classify ( Example & pce );
+    int classify_optimize ( Example & pce );
+
+    /** get all leaf nodes for an given example (or inner nodes if depth is set to the level) */
+    void getLeafNodes ( Example & pce,
+                        std::vector<DecisionNode *> & leafNodes,
+                        int depth = 100000 );
+    /** get all leaf nodes (or inner nodes if depth is set to the level) */
+    void getAllLeafNodes ( std::vector<DecisionNode *> & leafNodes );
+
+    /** perform training using a given feature pool and some training data */
+    virtual void train ( FeaturePool & fp,
+                         Examples & examples );
+
+    /** enumerate all nodes within the trees */
+    void indexDescendants ( std::map<DecisionNode *, std::pair<long, int> > & index ) const;
+
+    /** reset all counters in all nodes contained in the forest */
+    void resetCounters ();
+
+    /** direct access to all trees */
+    const std::vector<DecisionTree *> & getForest () const
+    {
+      return forest;
+    };
+
+    /** direct write access to all trees */
+    std::vector<DecisionTree *> & getForestNonConst ()
+    {
+      return forest;
+    };
+
+    /** clone this object */
+    FeaturePoolClassifier *clone () const;
+
+    /** get out of bag estimates */
+    std::vector<std::pair<double, int> > & getOutOfBagResults ()
+    {
+      return oobResults;
+    };
+
+    /** set the number of trees */
+    void setComplexity ( int size );
+
+    /** IO functions */
+    void restore ( std::istream & is, int format = 0 );
+    void store ( std::ostream & os, int format = 0 ) const;
+    void clear ();
+
 
 };
 

+ 71 - 67
classifier/kernelclassifier/GPLaplaceOptimizationProblem.h

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file GPLaplaceOptimizationProblem.h
 * @author Erik Rodner
 * @date 12/09/2009
@@ -16,8 +16,9 @@
 #include "LaplaceApproximation.h"
 #include "LikelihoodFunction.h"
 
-namespace OBJREC {
-  
+namespace OBJREC
+{
+
 /** @class GPLaplaceOptimizationProblem
  * Hyperparameter Optimization Problem for GP with Laplace Approximation
  *
@@ -26,70 +27,73 @@ namespace OBJREC {
 class GPLaplaceOptimizationProblem : public NICE::OptimizationProblemFirst
 {
 
-    protected:
-		KernelData *kernelData;
-		
-		NICE::VVector y;
-
-		double bestAvgLooError;
-		NICE::Vector bestLooParameters;
-		
-		ParameterizedKernel *kernel;
-
-		bool verbose;
-
-		const LikelihoodFunction *likelihoodFunction;
-		
-		std::vector<LaplaceApproximation *> laplaceApproximation;
-
-    public:
-  
-  
-  		/** initialize the optimization problem of laplace approximation integrated in
-		 *  GP
-		 *  @param kernelData object containing kernel matrix and other stuff
-		 *  @param y labels which have to -1 or 1
-		 *  @param kernel a parameterized kernel which provides derivations
-		 *  @param likelihoodFunction the type of the likelihood p(y_i|f_i), e.g. cumulative gaussian
-		 *  @param laplaceApproximation object containing cached matrices of the laplaceApproximation
-		 *  @param verbose print some status messages for debugging and boring work days
-		 **/
-     	GPLaplaceOptimizationProblem ( KernelData *kernelData, const NICE::Vector & y, 
-			ParameterizedKernel *kernel, const LikelihoodFunction *likelihoodFunction,
-			LaplaceApproximation *laplaceApproximation,
-			bool verbose );
-
-		/** initialize the multi-task optimization problem of laplace approximation 
-		 * integrated in GP
-		 *  @param kernelData object containing kernel matrix and other stuff
-		 *  @param y vector of labels which have to -1 or 1
-		 *  @param kernel a parameterized kernel which provides derivations
-		 *  @param likelihoodFunction the type of the likelihood p(y_i|f_i), e.g. cumulative gaussian
-		 *  @param laplaceApproximation object containing cached matrices of the laplaceApproximation
-		 *  @param verbose print some status messages for debugging and boring work days
-		 **/
-     	GPLaplaceOptimizationProblem ( KernelData *kernelData, const NICE::VVector & y, 
-			ParameterizedKernel *kernel, const LikelihoodFunction *likelihoodFunction,
-			const std::vector<LaplaceApproximation *> & laplaceApproximation,
-			bool verbose );
-
-		/** R.I.P. */
-		~GPLaplaceOptimizationProblem();
-
-		/** compute the negative log likelihood of the laplace approximation integrated GP */
-		double computeObjective();
-
-		/** compute the gradient of the negative log likelihood of the laplace approximation */
-		void computeGradient( NICE::Vector& newGradient );
-
-		/** set hyperparameters of the current kernel */
-		void setParameters ( const NICE::Vector & newParameters ) { parameters() = newParameters; };
-
-		/** use loo parameters */
-		void useLooParameters ();
-		
-		/** update cached stuff like cholesky factorization (KernelData.h) */
-		void update();
+  protected:
+    KernelData *kernelData;
+
+    NICE::VVector y;
+
+    double bestAvgLooError;
+    NICE::Vector bestLooParameters;
+
+    ParameterizedKernel *kernel;
+
+    bool verbose;
+
+    const LikelihoodFunction *likelihoodFunction;
+
+    std::vector<LaplaceApproximation *> laplaceApproximation;
+
+  public:
+
+
+    /** initialize the optimization problem of laplace approximation integrated in
+    *  GP
+    *  @param kernelData object containing kernel matrix and other stuff
+    *  @param y labels which have to -1 or 1
+    *  @param kernel a parameterized kernel which provides derivations
+    *  @param likelihoodFunction the type of the likelihood p(y_i|f_i), e.g. cumulative gaussian
+    *  @param laplaceApproximation object containing cached matrices of the laplaceApproximation
+    *  @param verbose print some status messages for debugging and boring work days
+    **/
+    GPLaplaceOptimizationProblem ( KernelData *kernelData, const NICE::Vector & y,
+                                   ParameterizedKernel *kernel, const LikelihoodFunction *likelihoodFunction,
+                                   LaplaceApproximation *laplaceApproximation,
+                                   bool verbose );
+
+    /** initialize the multi-task optimization problem of laplace approximation
+     * integrated in GP
+     *  @param kernelData object containing kernel matrix and other stuff
+     *  @param y vector of labels which have to -1 or 1
+     *  @param kernel a parameterized kernel which provides derivations
+     *  @param likelihoodFunction the type of the likelihood p(y_i|f_i), e.g. cumulative gaussian
+     *  @param laplaceApproximation object containing cached matrices of the laplaceApproximation
+     *  @param verbose print some status messages for debugging and boring work days
+     **/
+    GPLaplaceOptimizationProblem ( KernelData *kernelData, const NICE::VVector & y,
+                                   ParameterizedKernel *kernel, const LikelihoodFunction *likelihoodFunction,
+                                   const std::vector<LaplaceApproximation *> & laplaceApproximation,
+                                   bool verbose );
+
+    /** R.I.P. */
+    ~GPLaplaceOptimizationProblem();
+
+    /** compute the negative log likelihood of the laplace approximation integrated GP */
+    double computeObjective();
+
+    /** compute the gradient of the negative log likelihood of the laplace approximation */
+    void computeGradient ( NICE::Vector& newGradient );
+
+    /** set hyperparameters of the current kernel */
+    void setParameters ( const NICE::Vector & newParameters )
+    {
+      parameters() = newParameters;
+    };
+
+    /** use loo parameters */
+    void useLooParameters ();
+
+    /** update cached stuff like cholesky factorization (KernelData.h) */
+    void update();
 };
 
 }

+ 57 - 46
classifier/kernelclassifier/KCGPLaplace.h

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file KCGPLaplace.h
 * @brief Gaussian Process Regression for Classification
 * @author Erik Rodner
@@ -14,55 +14,66 @@
 #include "vislearning/classifier/kernelclassifier/LikelihoodFunction.h"
 
 #undef ROADWORKS
-#define ROADWORKS fthrow(Exception, "Persistent interface not implemented!");
+#define ROADWORKS fthrow(NICE::Exception, "Persistent interface not implemented!");
+
+namespace OBJREC
+{
 
-namespace OBJREC {
- 
 /** Gaussian Process Regression for Classification */
 class KCGPLaplace : public KernelClassifier
 {
-	protected:
-	
-		enum {
-			OPTIMIZATION_METHOD_RASMUSSEN = 0,
-			OPTIMIZATION_METHOD_TRUSTREGION
-		};
-
-
-		int optimizationMethod;
-
-		bool verbose;
-		bool optimizeParameters;
-
-		NICE::Vector y;
-
-		LaplaceApproximation laplaceApproximation;
-		LikelihoodFunction *likelihoodFunction;
-
-    public:
-  
-	/** simple constructor */
-	KCGPLaplace( const NICE::Config *conf, Kernel *kernel = NULL, const std::string & section = "KCGPLaplace" );
-
-	/** copy constructor */
-	KCGPLaplace( const KCGPLaplace & src );
-      
-	/** simple destructor */
-	virtual ~KCGPLaplace();
-  	
-	/** teach the classifier with a kernel matrix and the corresponding class labels @param y ! */
-	void teach ( KernelData *kernelData, const NICE::Vector & y );
-  	
-	/** classify an example by using its kernel values with the training set,
-		be careful with the order in @param kernelVector */
-	virtual ClassificationResult classifyKernel ( const NICE::Vector & kernelVector, double kernelSelf ) const;
-  
-  	/** clone this object */
-	KCGPLaplace *clone() const;
-
-	void restore(std::istream&, int) { ROADWORKS };
-	void store(std::ostream&, int) const { ROADWORKS };
-	void clear() { ROADWORKS };
+  protected:
+
+    enum
+    {
+      OPTIMIZATION_METHOD_RASMUSSEN = 0,
+      OPTIMIZATION_METHOD_TRUSTREGION
+    };
+
+
+    int optimizationMethod;
+
+    bool verbose;
+    bool optimizeParameters;
+
+    NICE::Vector y;
+
+    LaplaceApproximation laplaceApproximation;
+    LikelihoodFunction *likelihoodFunction;
+
+  public:
+
+    /** simple constructor */
+    KCGPLaplace ( const NICE::Config *conf, Kernel *kernel = NULL, const std::string & section = "KCGPLaplace" );
+
+    /** copy constructor */
+    KCGPLaplace ( const KCGPLaplace & src );
+
+    /** simple destructor */
+    virtual ~KCGPLaplace();
+
+    /** teach the classifier with a kernel matrix and the corresponding class labels @param y ! */
+    void teach ( KernelData *kernelData, const NICE::Vector & y );
+
+    /** classify an example by using its kernel values with the training set,
+     be careful with the order in @param kernelVector */
+    virtual ClassificationResult classifyKernel ( const NICE::Vector & kernelVector, double kernelSelf ) const;
+
+    /** clone this object */
+    KCGPLaplace *clone() const;
+
+    void restore ( std::istream&, int )
+    {
+      ROADWORKS
+    };
+    void store ( std::ostream&, int ) const
+    {
+      ROADWORKS
+    };
+    void clear()
+    {
+      ROADWORKS
+    };
 };
 
 

+ 43 - 33
classifier/kernelclassifier/KCGPLaplaceOneVsAll.h

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file KCGPLaplaceOneVsAll.h
 * @author Erik Rodner
 * @date 12/10/2009
@@ -15,10 +15,11 @@
 #include "vislearning/regression/gpregression/modelselcrit/genericGPModelSelection.h"
 #include "vislearning/classifier/kernelclassifier/LikelihoodFunction.h"
 
-namespace OBJREC {
-  
+namespace OBJREC
+{
+
 #undef ROADWORKS
-#define ROADWORKS fthrow(Exception, "Persistent interface not implemented!");
+#define ROADWORKS fthrow(NICE::Exception, "Persistent interface not implemented!");
 
 /** @class KCGPLaplaceOneVsAll
  * One vs. All GP Laplace classifier with joint optimization
@@ -29,44 +30,53 @@ namespace OBJREC {
 class KCGPLaplaceOneVsAll : public KernelClassifier
 {
 
-    protected:
-		NICE::Config confCopy;
-		std::string confSection;
+  protected:
+    NICE::Config confCopy;
+    std::string confSection;
+
+    bool optimizeParameters;
+
+    bool verbose;
+
+    int maxIterations;
+
+    std::vector<LaplaceApproximation *> laplaceApproximations;
+    LikelihoodFunction *likelihoodFunction;
 
-		bool optimizeParameters;
+    NICE::VVector ySetZeroMean;
+    NICE::VectorT<int> classnos;
 
-		bool verbose;
+    //GPMSCLooLikelihoodRegression *modelselcrit;
 
-		int maxIterations;
-	
-		std::vector<LaplaceApproximation *> laplaceApproximations;
-		LikelihoodFunction *likelihoodFunction;
+    bool useLooParameters;
 
-		NICE::VVector ySetZeroMean;
-		NICE::VectorT<int> classnos;
+  public:
 
-		//GPMSCLooLikelihoodRegression *modelselcrit;
+    /** simple constructor */
+    KCGPLaplaceOneVsAll ( const NICE::Config *conf, Kernel *kernelFunction = NULL, const std::string & section = "KCGPLaplaceOneVsAll" );
 
-		bool useLooParameters;
+    /** simple destructor */
+    virtual ~KCGPLaplaceOneVsAll();
 
-    public:
-		
-		/** simple constructor */
-		KCGPLaplaceOneVsAll( const NICE::Config *conf, Kernel *kernelFunction = NULL, const std::string & section = "KCGPLaplaceOneVsAll" );
-		  
-		/** simple destructor */
-		virtual ~KCGPLaplaceOneVsAll();
-     
-	 	/** teach the classifier with a kernel matrix and the corresponding class labels @param y ! */
-		void teach ( KernelData *kernelData, const NICE::Vector & y );
+    /** teach the classifier with a kernel matrix and the corresponding class labels @param y ! */
+    void teach ( KernelData *kernelData, const NICE::Vector & y );
 
-		/** classify an example by using its kernel values with the training set,
-			be careful with the order in @param kernelVector */
-		ClassificationResult classifyKernel ( const NICE::Vector & kernelVector, double kernelSelf ) const;
+    /** classify an example by using its kernel values with the training set,
+     be careful with the order in @param kernelVector */
+    ClassificationResult classifyKernel ( const NICE::Vector & kernelVector, double kernelSelf ) const;
 
-		void restore(std::istream&, int) { ROADWORKS };
-		void store(std::ostream&, int) const { ROADWORKS };
-		void clear() { ROADWORKS };
+    void restore ( std::istream&, int )
+    {
+      ROADWORKS
+    };
+    void store ( std::ostream&, int ) const
+    {
+      ROADWORKS
+    };
+    void clear()
+    {
+      ROADWORKS
+    };
 
 };
 

+ 47 - 37
classifier/kernelclassifier/KCGPOneClass.h

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file KCGPOneClass.h
 * @brief One-Class Gaussian Process Regression for Classification
 * @author Erik Rodner + Mi.Ke.
@@ -14,50 +14,60 @@
 #include "vislearning/regression/regressionbase/RegressionAlgorithmKernel.h"
 
 #undef ROADWORKS
-#define ROADWORKS fthrow(Exception, "Persistent interface not implemented!");
+#define ROADWORKS fthrow(NICE::Exception, "Persistent interface not implemented!");
 
 #define VARIANCE_DETECTION_MODE 1
 #define MEAN_DETECTION_MODE 2
 
-namespace OBJREC {
- 
+namespace OBJREC
+{
+
 /** Gaussian Process Regression for One-Class Classification  (actually same as binary, don't use parameter optimization!!!)*/
 class KCGPOneClass : public KernelClassifier
 {
 
-    protected:
-		RegressionAlgorithmKernel *regressionAlgorithm;
-		NICE::Matrix InverseKernelMatrix; //only used when 'variance mode' is used and computeInverse=true
-		KernelData *kernelData; ////only used when 'variance mode' is used and computeInverse=false
-		NICE::Vector y;
-		int mode;
-		bool computeInverse;
-		double staticNoise;
-
-    public:
-  
-	/** simple constructor */
-	KCGPOneClass( const NICE::Config *conf, Kernel *kernel = NULL, const std::string & section = "OneClassGP" );
-
-	/** copy constructor */
-	KCGPOneClass( const KCGPOneClass & src );
-      
-	/** simple destructor */
-	virtual ~KCGPOneClass();
-  	
-	/** teach the classifier with a kernel matrix and the corresponding class labels @param y ! */
-	void teach ( KernelData *kernelData, const NICE::Vector & y );
-  	
-	/** classify an example by using its kernel values with the training set,
-		be careful with the order in @param kernelVector */
-	virtual ClassificationResult classifyKernel ( const NICE::Vector & kernelVector, double kernelSelf ) const;
-  
-  	/** clone this object */
-	KCGPOneClass *clone() const;
-
-	void restore(std::istream&, int) { ROADWORKS };
-	void store(std::ostream&, int) const { ROADWORKS };
-	void clear() { ROADWORKS };
+  protected:
+    RegressionAlgorithmKernel *regressionAlgorithm;
+    NICE::Matrix InverseKernelMatrix; //only used when 'variance mode' is used and computeInverse=true
+    KernelData *kernelData; ////only used when 'variance mode' is used and computeInverse=false
+    NICE::Vector y;
+    int mode;
+    bool computeInverse;
+    double staticNoise;
+
+  public:
+
+    /** simple constructor */
+    KCGPOneClass ( const NICE::Config *conf, Kernel *kernel = NULL, const std::string & section = "OneClassGP" );
+
+    /** copy constructor */
+    KCGPOneClass ( const KCGPOneClass & src );
+
+    /** simple destructor */
+    virtual ~KCGPOneClass();
+
+    /** teach the classifier with a kernel matrix and the corresponding class labels @param y ! */
+    void teach ( KernelData *kernelData, const NICE::Vector & y );
+
+    /** classify an example by using its kernel values with the training set,
+     be careful with the order in @param kernelVector */
+    virtual ClassificationResult classifyKernel ( const NICE::Vector & kernelVector, double kernelSelf ) const;
+
+    /** clone this object */
+    KCGPOneClass *clone() const;
+
+    void restore ( std::istream&, int )
+    {
+      ROADWORKS
+    };
+    void store ( std::ostream&, int ) const
+    {
+      ROADWORKS
+    };
+    void clear()
+    {
+      ROADWORKS
+    };
 };
 
 

+ 66 - 65
classifier/kernelclassifier/KCGPRegOneVsAll.h

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file KCGPRegOneVsAll.h
 * @author Erik Rodner
 * @date 12/10/2009
@@ -14,10 +14,11 @@
 
 #include <vector>
 
-namespace OBJREC {
-  
+namespace OBJREC
+{
+
 #undef ROADWORKS
-#define ROADWORKS fthrow(Exception, "Persistent interface not implemented!");
+#define ROADWORKS fthrow(NICE::Exception, "Persistent interface not implemented!");
 
 /** @class KCGPRegOneVsAll
  * One vs. All GP regression classifier with joint optimization
@@ -28,67 +29,67 @@ namespace OBJREC {
 class KCGPRegOneVsAll : public KernelClassifier
 {
 
-    protected:
-		/** set of classifiers with the corresponding class */
-		std::vector< std::pair<int, RegGaussianProcess *> > classifiers;
-	
-		/** clone from prototype to generate new classifiers */
-		const RegGaussianProcess *prototype;
-
-		/** whether to optimize hyper-parameters */
-		bool optimizeParameters;
-
-		/** tell us something about what you are doing */
-		bool verbose;
-
-		/** maximum number of iterations of the hyper-parameter estimation */
-		int maxIterations;
-
-		TraceApproximation *traceApproximation;
-		GPMSCLooLikelihoodRegression *modelselcrit;
-
-		/** use the hyperparameters which lead to the best leave-one-out criterion */
-		bool useLooParameters;
-
-		/** whether to invest some computation time to estimate the uncertainty of the prediction */
-		bool computeUncertainty;
-
-		/** for computing uncertainties we need the cholesky decomposition of the kernel matrix */
-		NICE::Matrix choleskyMatrix;
-
-		/** whether to calibrate the probabilities using uncertainty estimates */
-		bool calibrateProbabilities;
-
-		/** how many samples should we draw to estimate the probabilities */
-		uint numSamplesCalibration;
-
-    public:
-  		/** simplest constructor */
-		KCGPRegOneVsAll(){};
-	    	
-		/** simple constructor */
-		KCGPRegOneVsAll( const NICE::Config *conf, Kernel *kernelFunction = NULL, const std::string & section = "KCGPRegOneVsAll" );
-		  
-		/** copy constructor */
-		KCGPRegOneVsAll( const KCGPRegOneVsAll &vcova );
-		
-		/** simple destructor */
-		virtual ~KCGPRegOneVsAll();
-     
-	 	/** teach the classifier with a kernel matrix and the corresponding class labels @param y ! */
-		void teach ( KernelData *kernelData, const NICE::Vector & y );
-		void teach ( KernelData *kernelData, const std::vector<double> & y );
-
-		/** classify an example by using its kernel values with the training set,
-			be careful with the order in @param kernelVector */
-		ClassificationResult classifyKernel ( const NICE::Vector & kernelVector, double kernelSelf ) const;
-
-		void restore(std::istream&, int);
-		void store(std::ostream&, int) const;
-		void clear();
-		
-		/** clone this object */
-		virtual KCGPRegOneVsAll *clone(void) const;
+  protected:
+    /** set of classifiers with the corresponding class */
+    std::vector< std::pair<int, RegGaussianProcess *> > classifiers;
+
+    /** clone from prototype to generate new classifiers */
+    const RegGaussianProcess *prototype;
+
+    /** whether to optimize hyper-parameters */
+    bool optimizeParameters;
+
+    /** tell us something about what you are doing */
+    bool verbose;
+
+    /** maximum number of iterations of the hyper-parameter estimation */
+    int maxIterations;
+
+    TraceApproximation *traceApproximation;
+    GPMSCLooLikelihoodRegression *modelselcrit;
+
+    /** use the hyperparameters which lead to the best leave-one-out criterion */
+    bool useLooParameters;
+
+    /** whether to invest some computation time to estimate the uncertainty of the prediction */
+    bool computeUncertainty;
+
+    /** for computing uncertainties we need the cholesky decomposition of the kernel matrix */
+    NICE::Matrix choleskyMatrix;
+
+    /** whether to calibrate the probabilities using uncertainty estimates */
+    bool calibrateProbabilities;
+
+    /** how many samples should we draw to estimate the probabilities */
+    uint numSamplesCalibration;
+
+  public:
+    /** simplest constructor */
+    KCGPRegOneVsAll() {};
+
+    /** simple constructor */
+    KCGPRegOneVsAll ( const NICE::Config *conf, Kernel *kernelFunction = NULL, const std::string & section = "KCGPRegOneVsAll" );
+
+    /** copy constructor */
+    KCGPRegOneVsAll ( const KCGPRegOneVsAll &vcova );
+
+    /** simple destructor */
+    virtual ~KCGPRegOneVsAll();
+
+    /** teach the classifier with a kernel matrix and the corresponding class labels @param y ! */
+    void teach ( KernelData *kernelData, const NICE::Vector & y );
+    void teach ( KernelData *kernelData, const std::vector<double> & y );
+
+    /** classify an example by using its kernel values with the training set,
+     be careful with the order in @param kernelVector */
+    ClassificationResult classifyKernel ( const NICE::Vector & kernelVector, double kernelSelf ) const;
+
+    void restore ( std::istream&, int );
+    void store ( std::ostream&, int ) const;
+    void clear();
+
+    /** clone this object */
+    virtual KCGPRegOneVsAll *clone ( void ) const;
 
 };
 

+ 44 - 34
classifier/kernelclassifier/KCGPRegression.h

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file KCGPRegression.h
 * @brief Gaussian Process Regression for Classification
 * @author Erik Rodner
@@ -15,44 +15,54 @@
 #include "vislearning/regression/regressionbase/TeachWithInverseKernelMatrix.h"
 
 #undef ROADWORKS
-#define ROADWORKS fthrow(Exception, "Persistent interface not implemented!");
+#define ROADWORKS fthrow(NICE::Exception, "Persistent interface not implemented!");
+
+namespace OBJREC
+{
 
-namespace OBJREC {
- 
 /** Gaussian Process Regression for Classification */
 class KCGPRegression : public KernelClassifier
 {
 
-    protected:
-		RegressionAlgorithmKernel *regressionAlgorithm;
-		NICE::Vector y;
-
-    public:
-  
-	/** simple constructor */
-	KCGPRegression( const NICE::Config *conf, Kernel *kernel = NULL, const std::string & section = "KCGPRegression" );
-
-	/** copy constructor */
-	KCGPRegression( const KCGPRegression & src );
-      
-	/** simple destructor */
-	virtual ~KCGPRegression();
-  	
-	/** teach the classifier with a kernel matrix and the corresponding class labels @param y ! */
-	void teach ( KernelData *kernelData, const NICE::Vector & y );
-  	
-	/** classify an example by using its kernel values with the training set,
-		be careful with the order in @param kernelVector */
-	virtual ClassificationResult classifyKernel ( const NICE::Vector & kernelVector, double kernelSelf ) const;
-  
-  	/** clone this object */
-	KCGPRegression *clone() const;
-
-	void restore(std::istream&, int) { ROADWORKS };
-	void store(std::ostream&, int) const { ROADWORKS };
-	void clear() { ROADWORKS };
-
-	bool getOptimizeKernelParameters () const;
+  protected:
+    RegressionAlgorithmKernel *regressionAlgorithm;
+    NICE::Vector y;
+
+  public:
+
+    /** simple constructor */
+    KCGPRegression ( const NICE::Config *conf, Kernel *kernel = NULL, const std::string & section = "KCGPRegression" );
+
+    /** copy constructor */
+    KCGPRegression ( const KCGPRegression & src );
+
+    /** simple destructor */
+    virtual ~KCGPRegression();
+
+    /** teach the classifier with a kernel matrix and the corresponding class labels @param y ! */
+    void teach ( KernelData *kernelData, const NICE::Vector & y );
+
+    /** classify an example by using its kernel values with the training set,
+     be careful with the order in @param kernelVector */
+    virtual ClassificationResult classifyKernel ( const NICE::Vector & kernelVector, double kernelSelf ) const;
+
+    /** clone this object */
+    KCGPRegression *clone() const;
+
+    void restore ( std::istream&, int )
+    {
+      ROADWORKS
+    };
+    void store ( std::ostream&, int ) const
+    {
+      ROADWORKS
+    };
+    void clear()
+    {
+      ROADWORKS
+    };
+
+    bool getOptimizeKernelParameters () const;
 };
 
 

+ 46 - 36
classifier/kernelclassifier/KCMinimumEnclosingBall.h

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file KCGPOneClass.h
 * @brief One-Class Gaussian Process Regression for Classification
 * @author Erik Rodner + Mi.Ke.
@@ -12,7 +12,7 @@
 #include "vislearning/math/kernels/ParameterizedKernel.h"
 
 #undef ROADWORKS
-#define ROADWORKS fthrow(Exception, "Persistent interface not implemented!");
+#define ROADWORKS fthrow(NICE::Exception, "Persistent interface not implemented!");
 
 #define VARIANCE_DETECTION_MODE 1
 #define MEAN_DETECTION_MODE 2
@@ -21,44 +21,54 @@
 #include "vislearning/optimization/quadprog/Array.h"
 
 
-namespace OBJREC {
- 
+namespace OBJREC
+{
+
 /** Minimum Enclosing Ball Algorithm (For stationary kernels equal to 1-SVM)*/
 class KCMinimumEnclosingBall : public KernelClassifier
 {
 
-    protected:
-		int trainingSize;
-		double radius;
-		double aKa;
-		double nu;
-		QuadProgPP::Matrix<double> TwoK,Eye,Ones,ones;
-		QuadProgPP::Vector<double> alpha,b,minusDiagK,minusOne,zeros;
-
-    public:
-  
-	/** simple constructor */
-	KCMinimumEnclosingBall( const NICE::Config *conf, Kernel *kernel = NULL, const std::string & section = "KCGMinimumEnclosingBall" );
-
-	/** copy constructor */
-	KCMinimumEnclosingBall( const KCMinimumEnclosingBall & src );
-      
-	/** simple destructor */
-	virtual ~KCMinimumEnclosingBall();
-  	
-	/** teach the classifier with a kernel matrix and the corresponding class labels @param y ! */
-	void teach ( KernelData *kernelData, const NICE::Vector & y );
-  	
-	/** classify an example by using its kernel values with the training set,
-		be careful with the order in @param kernelVector */
-	virtual ClassificationResult classifyKernel ( const NICE::Vector & kernelVector, double kernelSelf  ) const;
-  
-  	/** clone this object */
-	KCMinimumEnclosingBall *clone() const;
-
-	void restore(std::istream&, int) { ROADWORKS };
-	void store(std::ostream&, int) const { ROADWORKS };
-	void clear() { ROADWORKS };
+  protected:
+    int trainingSize;
+    double radius;
+    double aKa;
+    double nu;
+    QuadProgPP::Matrix<double> TwoK,Eye,Ones,ones;
+    QuadProgPP::Vector<double> alpha,b,minusDiagK,minusOne,zeros;
+
+  public:
+
+    /** simple constructor */
+    KCMinimumEnclosingBall ( const NICE::Config *conf, Kernel *kernel = NULL, const std::string & section = "KCGMinimumEnclosingBall" );
+
+    /** copy constructor */
+    KCMinimumEnclosingBall ( const KCMinimumEnclosingBall & src );
+
+    /** simple destructor */
+    virtual ~KCMinimumEnclosingBall();
+
+    /** teach the classifier with a kernel matrix and the corresponding class labels @param y ! */
+    void teach ( KernelData *kernelData, const NICE::Vector & y );
+
+    /** classify an example by using its kernel values with the training set,
+     be careful with the order in @param kernelVector */
+    virtual ClassificationResult classifyKernel ( const NICE::Vector & kernelVector, double kernelSelf ) const;
+
+    /** clone this object */
+    KCMinimumEnclosingBall *clone() const;
+
+    void restore ( std::istream&, int )
+    {
+      ROADWORKS
+    };
+    void store ( std::ostream&, int ) const
+    {
+      ROADWORKS
+    };
+    void clear()
+    {
+      ROADWORKS
+    };
 
 };
 

+ 39 - 29
classifier/kernelclassifier/KCOneVsAll.h

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file KCOneVsAll.h
 * @author Erik Rodner
 * @date 12/10/2009
@@ -9,43 +9,53 @@
 
 #include "vislearning/classifier/classifierbase/KernelClassifier.h"
 
-namespace OBJREC {
-  
+namespace OBJREC
+{
+
 #undef ROADWORKS
-#define ROADWORKS fthrow(Exception, "Persistent interface not implemented!");
+#define ROADWORKS fthrow(NICE::Exception, "Persistent interface not implemented!");
 
 /** @class KCOneVsAll
- * One vs. All interface for kernel classifiers 
+ * One vs. All interface for kernel classifiers
  *
  * @author Erik Rodner
  */
 class KCOneVsAll : public KernelClassifier
 {
 
-    protected:
-		std::vector< std::pair<int, KernelClassifier *> > classifiers;
-		const KernelClassifier *prototype;
-		double noiseSigma;
-		bool verbose;
-
-    public:
-  
-		/** simple constructor */
-		KCOneVsAll( const NICE::Config *conf, const KernelClassifier *prototype, const std::string & section = "KCOneVsAll" );
-		  
-		/** simple destructor */
-		virtual ~KCOneVsAll();
-     
-	 	/** teach the classifier with a kernel matrix and the corresponding class labels @param y ! */
-		void teach ( KernelData *kernelData, const NICE::Vector & y );
-
-		/** classify an example by using its kernel values with the training set,
-			be careful with the order in @param kernelVector */
-		ClassificationResult classifyKernel ( const NICE::Vector & kernelVector, double kernelSelf ) const;
-
-		void restore(std::istream&, int) { ROADWORKS };
-		void store(std::ostream&, int) const { ROADWORKS };
-		void clear() { ROADWORKS };
+  protected:
+    std::vector< std::pair<int, KernelClassifier *> > classifiers;
+    const KernelClassifier *prototype;
+    double noiseSigma;
+    bool verbose;
+
+  public:
+
+    /** simple constructor */
+    KCOneVsAll ( const NICE::Config *conf, const KernelClassifier *prototype, const std::string & section = "KCOneVsAll" );
+
+    /** simple destructor */
+    virtual ~KCOneVsAll();
+
+    /** teach the classifier with a kernel matrix and the corresponding class labels @param y ! */
+    void teach ( KernelData *kernelData, const NICE::Vector & y );
+
+    /** classify an example by using its kernel values with the training set,
+     be careful with the order in @param kernelVector */
+    ClassificationResult classifyKernel ( const NICE::Vector & kernelVector, double kernelSelf ) const;
+
+    void restore ( std::istream&, int )
+    {
+      ROADWORKS
+    };
+    void store ( std::ostream&, int ) const
+    {
+      ROADWORKS
+    };
+    void clear()
+    {
+      ROADWORKS
+    };
 
 };
 

+ 27 - 26
classifier/kernelclassifier/LHCumulativeGauss.h

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file LHCumulativeGauss.h
 * @author Erik Rodner
 * @date 02/17/2010
@@ -9,38 +9,39 @@
 
 #include "LikelihoodFunction.h"
 
-namespace OBJREC {
-  
+namespace OBJREC
+{
+
 /** @class LHCumulativeGauss
- * cumulative gauss function 
+ * cumulative gauss function
  *
  * @author Erik Rodner
  */
 class LHCumulativeGauss : public LikelihoodFunction
 {
 
-    protected:
-		double lengthScale;
-		double bias;
-
-    public:
-
-		/** a length scale of the likelihood function correspondes
-		 * to a an inverse scaling of the gp prior, thus you
-		 * could optimize this parameter by optimizing a hyperparameter
-		 * of the kernel function */
-		LHCumulativeGauss( double lengthScale = 1.0, double bias = 0.0 );
- 
- 		/** needed for hyperparameter estimation */
-		double thirdgrad ( double y, double f ) const;
-		double hessian ( double y, double f ) const;
-		double gradient ( double y, double f ) const;
-		double logLike ( double y, double f ) const;
-		double likelihood ( double y, double f ) const;
-
-		double predictAnalytically ( double fmean, double fvariance ) const;
-		
-		static double stdNormPDF (double x);
+  protected:
+    double lengthScale;
+    double bias;
+
+  public:
+
+    /** a length scale of the likelihood function correspondes
+     * to a an inverse scaling of the gp prior, thus you
+     * could optimize this parameter by optimizing a hyperparameter
+     * of the kernel function */
+    LHCumulativeGauss ( double lengthScale = 1.0, double bias = 0.0 );
+
+    /** needed for hyperparameter estimation */
+    double thirdgrad ( double y, double f ) const;
+    double hessian ( double y, double f ) const;
+    double gradient ( double y, double f ) const;
+    double logLike ( double y, double f ) const;
+    double likelihood ( double y, double f ) const;
+
+    double predictAnalytically ( double fmean, double fvariance ) const;
+
+    static double stdNormPDF ( double x );
 };
 
 }

+ 66 - 47
classifier/kernelclassifier/LaplaceApproximation.h

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file LaplaceApproximation.h
 * @author Erik Rodner
 * @date 02/17/2010
@@ -11,59 +11,78 @@
 #include "vislearning/classifier/kernelclassifier/LikelihoodFunction.h"
 #include "vislearning/math/kernels/KernelData.h"
 
-namespace OBJREC {
-  
+namespace OBJREC
+{
+
 /** @class LaplaceApproximation
- * some utility functions for laplace approximation 
+ * some utility functions for laplace approximation
  *
  * @author Erik Rodner
  */
 class LaplaceApproximation
 {
 
-    protected:
-		/** optimization settings */
-		uint maxiterations;
-		double minimumDelta;
-		bool verbose;
-
-		/** useful variables */
-		NICE::Vector mode;
-		NICE::Vector hessianW;
-		NICE::Vector gradientL;
-		NICE::Matrix cholB;
-
-		NICE::Vector a;
-
-		double objective;
-		double noiseTerm;
-
-		void updateCache ( const NICE::Matrix & kernelMatrix, const NICE::Vector & y, const LikelihoodFunction *likelihoodFunction );
-
-    public:
-  
-  		/** use standard settings */
-		LaplaceApproximation();
-
-		/** simple constructor using config values for numerical details */
-		LaplaceApproximation( const NICE::Config *conf, const std::string & section = "LaplaceApproximation" );
-		  
-		/** simple destructor */
-		virtual ~LaplaceApproximation();
-  
-  		void approximate ( KernelData *kernelData, const NICE::Vector & y,
-					   const LikelihoodFunction *likelihoodFunction );
-
-		double predict ( const NICE::Vector & kernelVector, double kernelSelf, const NICE::Vector & y, 
-				const LikelihoodFunction *likelihoodFunction ) const;
-
-		const NICE::Vector & getMode () const { return mode; };
-		const NICE::Vector & getHessian () const { return hessianW; };
-		const NICE::Vector & getGradient () const { return gradientL; };
-		const NICE::Vector & getAVector () const { return a; };
-		const NICE::Matrix & getCholeskyB () const { return cholB; };
-
-		double getObjective () const { return objective; };
+  protected:
+    /** optimization settings */
+    uint maxiterations;
+    double minimumDelta;
+    bool verbose;
+
+    /** useful variables */
+    NICE::Vector mode;
+    NICE::Vector hessianW;
+    NICE::Vector gradientL;
+    NICE::Matrix cholB;
+
+    NICE::Vector a;
+
+    double objective;
+    double noiseTerm;
+
+    void updateCache ( const NICE::Matrix & kernelMatrix, const NICE::Vector & y, const LikelihoodFunction *likelihoodFunction );
+
+  public:
+
+    /** use standard settings */
+    LaplaceApproximation();
+
+    /** simple constructor using config values for numerical details */
+    LaplaceApproximation ( const NICE::Config *conf, const std::string & section = "LaplaceApproximation" );
+
+    /** simple destructor */
+    virtual ~LaplaceApproximation();
+
+    void approximate ( KernelData *kernelData, const NICE::Vector & y,
+                       const LikelihoodFunction *likelihoodFunction );
+
+    double predict ( const NICE::Vector & kernelVector, double kernelSelf, const NICE::Vector & y,
+                     const LikelihoodFunction *likelihoodFunction ) const;
+
+    const NICE::Vector & getMode () const
+    {
+      return mode;
+    };
+    const NICE::Vector & getHessian () const
+    {
+      return hessianW;
+    };
+    const NICE::Vector & getGradient () const
+    {
+      return gradientL;
+    };
+    const NICE::Vector & getAVector () const
+    {
+      return a;
+    };
+    const NICE::Matrix & getCholeskyB () const
+    {
+      return cholB;
+    };
+
+    double getObjective () const
+    {
+      return objective;
+    };
 };
 
 }

+ 39 - 44
classifier/vclassifier/VCAmitSVM.h

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file VCAmitSVM.h
 * @brief interface to the svm generalization of Amit et al. 2007
 * @author Erik Rodner
@@ -10,57 +10,52 @@
 
 #include "core/vector/VectorT.h"
 #include "core/vector/MatrixT.h"
- 
+
 #include "VCLearnFromSC.h"
 
 
-namespace OBJREC {
+namespace OBJREC
+{
 
 /** interface to the svm generalization of Amit et al. 2007 */
 class VCAmitSVM : public VCLearnFromSC
 {
 
-    protected:
-	double C;
-	double gamma;
-
-	// refactor-nice.pl: check this substitution
-	// old: string amitDir;
-	std::string amitDir;
-	// refactor-nice.pl: check this substitution
-	// old: string matlabExec;
-	std::string matlabExec;
-	// refactor-nice.pl: check this substitution
-	// old: string matlabArgs;
-	std::string matlabArgs;
-	
-    public:
-	// refactor-nice.pl: check this substitution
-	// old: Matrix W;
-	NICE::Matrix W;
-  
-	/** simple constructor */
-	VCAmitSVM( const NICE::Config *conf );
-      
-	/** simple destructor */
-	virtual ~VCAmitSVM();
-     
-	/** classify using simple vector */
-	// refactor-nice.pl: check this substitution
-	// old: virtual ClassificationResult classify ( const ice::Vector & x ) const;
-	virtual ClassificationResult classify ( const NICE::Vector & x ) const;
-
-	virtual void preTeach ( const LabeledSetVector & teachSet );
-
-	virtual void teach ( const LabeledSetVector & teachSet );
-
-	virtual void finishTeaching() {};
-
-	void restore ( std::istream & is, int format = 0 );
-
-	void store ( std::ostream & is, int format = 0 ) const;
-
-	void clear ();
+  protected:
+    double C;
+    double gamma;
+
+    std::string amitDir;
+
+    std::string matlabExec;
+
+    std::string matlabArgs;
+
+  public:
+
+    NICE::Matrix W;
+
+    /** simple constructor */
+    VCAmitSVM ( const NICE::Config *conf );
+
+    /** simple destructor */
+    virtual ~VCAmitSVM();
+
+    /** classify using simple vector */
+
+    virtual ClassificationResult classify ( const NICE::Vector & x ) const;
+
+    virtual void preTeach ( const LabeledSetVector & teachSet );
+
+    virtual void teach ( const LabeledSetVector & teachSet );
+
+    virtual void finishTeaching() {};
+
+    void restore ( std::istream & is, int format = 0 );
+
+    void store ( std::ostream & is, int format = 0 ) const;
+
+    void clear ();
 
 };
 

+ 28 - 27
classifier/vclassifier/VCCrossGeneralization.h

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file VCCrossGeneralization.h
 * @brief Combination of Classifiers
 * @author Erik Rodner
@@ -9,7 +9,7 @@
 #define VCCrossGeneralizationINCLUDE
 
 #ifdef NICE_USELIB_ICE
- 
+
 #include "VCLearnFromSC.h"
 
 #ifdef NICE_USELIB_ICE
@@ -19,47 +19,48 @@
 #include "core/basics/Config.h"
 
 
-namespace OBJREC {
+namespace OBJREC
+{
 
 /** Combination of Classifiers */
 class VCCrossGeneralization : public VCLearnFromSC
 {
 
-    protected:
-	bool useVotingNormalization;
+  protected:
+    bool useVotingNormalization;
+
+    VCSimpleGaussian gauss;
+
+    VCNearestNeighbour nnclassifier;
+
+    bool simpleGaussianFinished;
+
+    void normalizeVotings ( NICE::Vector & v ) const;
+
+  public:
 
-	VCSimpleGaussian gauss;
+    /** simple constructor */
+    VCCrossGeneralization ( const NICE::Config *conf );
 
-	VCNearestNeighbour nnclassifier;
+    /** simple destructor */
+    virtual ~VCCrossGeneralization();
 
-	bool simpleGaussianFinished;
-	
-	void normalizeVotings ( NICE::Vector & v ) const;
+    /** classify using simple vector */
 
-    public:
-  
-	/** simple constructor */
-	VCCrossGeneralization (const NICE::Config *conf);
-      
-	/** simple destructor */
-	virtual ~VCCrossGeneralization();
- 
-	/** classify using simple vector */
+    virtual ClassificationResult classify ( const NICE::Vector & x ) const;
 
-	virtual ClassificationResult classify ( const NICE::Vector & x ) const;
+    virtual void preTeach ( const LabeledSetVector & teachSet );
 
-	virtual void preTeach ( const LabeledSetVector & teachSet );
+    virtual void teach ( const LabeledSetVector & teachSet );
 
-	virtual void teach ( const LabeledSetVector & teachSet );
+    virtual void finishTeaching();
 
-	virtual void finishTeaching();
+    void restore ( std::istream & is, int format = 0 );
 
-	void restore ( std::istream & is, int format = 0 );
+    void store ( std::ostream & is, int format = 0 ) const;
 
-	void store ( std::ostream & is, int format = 0 ) const;
+    void clear ();
 
-	void clear ();
-    
 };
 
 

+ 35 - 31
classifier/vclassifier/VCOneVsOne.h

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file VCOneVsOne.h
 * @brief one-vs.-one svm voting
 * @author Erik Rodner
@@ -15,40 +15,44 @@
 #include "core/basics/triplet.h"
 
 
-namespace OBJREC {
+namespace OBJREC
+{
 
 /** one-vs.-one svm voting */
 class VCOneVsOne : public VecClassifier
 {
-    protected:
-	
-	VecClassifier *prototype;
-	std::vector< triplet<int, int, VecClassifier *> > classifiers;
-	bool use_weighted_voting;
-
-    public:
-  
-	/** simple constructor */
-	VCOneVsOne( const NICE::Config *conf, VecClassifier *prototype );
-      
-	/** simple destructor */
-	virtual ~VCOneVsOne();
-     
-	/** classify using simple vector */
-	ClassificationResult classify ( const NICE::Vector & x ) const;
-
-	/** classify using a simple vector */
-	void teach ( const LabeledSetVector & teachSet );
-	
-	void finishTeaching();
-
-
-	void read (const std::string& s, int format = 0);
-	void save (const std::string& s, int format = 0) const;
-
-	void clear () { classifiers.clear(); };
-	void store ( std::ostream & os, int format = 0 ) const;
-	void restore ( std::istream & is, int format = 0 );
+  protected:
+
+    VecClassifier *prototype;
+    std::vector< NICE::triplet<int, int, VecClassifier *> > classifiers;
+    bool use_weighted_voting;
+
+  public:
+
+    /** simple constructor */
+    VCOneVsOne ( const NICE::Config *conf, VecClassifier *prototype );
+
+    /** simple destructor */
+    virtual ~VCOneVsOne();
+
+    /** classify using simple vector */
+    ClassificationResult classify ( const NICE::Vector & x ) const;
+
+    /** classify using a simple vector */
+    void teach ( const LabeledSetVector & teachSet );
+
+    void finishTeaching();
+
+
+    void read ( const std::string& s, int format = 0 );
+    void save ( const std::string& s, int format = 0 ) const;
+
+    void clear ()
+    {
+      classifiers.clear();
+    };
+    void store ( std::ostream & os, int format = 0 ) const;
+    void restore ( std::istream & is, int format = 0 );
 };
 
 

+ 2 - 2
math/cluster/GMM.h

@@ -124,7 +124,7 @@ class GMM : public ClusterAlgorithm
      * @param vin input vector
      * @param probs BoV output vector
      */
-    void getProbs ( const NICE::Vector &vin, SparseVector &probs );
+    void getProbs ( const NICE::Vector &vin, NICE::SparseVector &probs );
 
     /**
      * returns the probabilities for each gaussian
@@ -138,7 +138,7 @@ class GMM : public ClusterAlgorithm
      * @param vin input vector
      * @param probs Fisher score output vector
      */
-    void getFisher ( const NICE::Vector &vin, SparseVector &probs );
+    void getFisher ( const NICE::Vector &vin, NICE::SparseVector &probs );
 
     /**
      *   init the GaussianMixture by selecting randomized mean vectors and using the coovariance of all features

+ 32 - 33
math/cluster/KMeansOnline.h

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file KMeansOnline.h
 * @brief online kmeans clustering
 * @author Erik Rodner
@@ -16,43 +16,42 @@
 #include "vislearning/cbaselib/Example.h"
 
 
-namespace OBJREC {
+namespace OBJREC
+{
 
 /** online kmeans clustering */
 class KMeansOnline : public ClusterOnline
 {
 
-    protected:
-	size_t numClusters;
-	double gamma;
-
-    public:
-  
-	/** simple constructor */
-	KMeansOnline( size_t numClusters, double gamma = 1.0 );
-      
-	/** simple destructor */
-	virtual ~KMeansOnline();
-
-	// refactor-nice.pl: check this substitution
-	// old: int updateClusters ( const Vector & x );
-	int updateClusters ( const NICE::Vector & x );
-	void init ();
-     
-	/**
-	 * Cluster algorithm using examples
-	 * @param ex input examples
-	 */
-	void cluster( const Examples &ex);
-	
-	/**
-	 * returns the distance to the centre of each cluster
-	 * @param vin input vector
-	 * @param dist distance
-	 * @param size how much centres should considered
-	 * @param hard use a hard assignment (all values = 1 or 0) or not
-		 */
-	void getDist(const NICE::Vector &vin, SparseVector &dist, int size = 1, bool hard = false);
+  protected:
+    size_t numClusters;
+    double gamma;
+
+  public:
+
+    /** simple constructor */
+    KMeansOnline ( size_t numClusters, double gamma = 1.0 );
+
+    /** simple destructor */
+    virtual ~KMeansOnline();
+
+    int updateClusters ( const NICE::Vector & x );
+    void init ();
+
+    /**
+     * Cluster algorithm using examples
+     * @param ex input examples
+     */
+    void cluster ( const Examples &ex );
+
+    /**
+     * returns the distance to the centre of each cluster
+     * @param vin input vector
+     * @param dist distance
+     * @param size how much centres should considered
+     * @param hard use a hard assignment (all values = 1 or 0) or not
+      */
+    void getDist ( const NICE::Vector &vin, NICE::SparseVector &dist, int size = 1, bool hard = false );
 };