Jelajahi Sumber

some formating

Bjoern Froehlich 13 tahun lalu
induk
melakukan
4bb8701bce

+ 1 - 1
cbaselib/ClassNames.cpp

@@ -441,7 +441,7 @@ void ClassNames::restore ( istream & is, int format )
     int myclassno;
 
     if ( ! ( is >> mytext ) ) break;
-    if( mytext == "end") break;
+    if ( mytext == "end" ) break;
     if ( ! ( is >> mycode ) ) break;
     if ( ! ( is >> myclassno ) ) break;
 

+ 80 - 80
cbaselib/ClassNames.h

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

+ 47 - 47
features/fpfeatures/HaarFeature.cpp

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

+ 40 - 40
features/fpfeatures/HaarFeature.h

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