Browse Source

read statt write

Bjoern Froehlich 13 years ago
parent
commit
6313b280e7

+ 9 - 10
baselib/ProgressBar.cpp

@@ -1,9 +1,8 @@
-/** 
+/**
  * @file ProgressBar.cpp
  * @brief Show a Progress-Bar with time estimation - threaded
  * @author Michael Koch
  * @date 25/03/2010
-
  */
 #include "core/image/ImageT.h"
 #include "core/vector/VectorT.h"
@@ -22,20 +21,20 @@ using namespace std;
 
 using namespace NICE;
 
-ProgressBar::ProgressBar( std::string a ) : ProgressBarQt(a, true)
+ProgressBar::ProgressBar ( std::string a ) : ProgressBarQt ( a, true )
 {
-    start();
+  start();
 }
 ProgressBar::~ProgressBar()
 {
-	terminate();
-	wait();
+  terminate();
+  wait();
 }
 void ProgressBar::run()
 {
- if(working)
- {
-	 sleep(1);
- }
+  if ( working )
+  {
+    sleep ( 1 );
+  }
 }
 

+ 7 - 7
baselib/ProgressBar.h

@@ -1,4 +1,4 @@
-/** 
+/**
  * @file ProgressBar.h
  * @brief Show a Progress-Bar with time estimation - threaded
  * @author Michael Koch
@@ -19,12 +19,12 @@ namespace OBJREC
 /** @brief show a Progress-Bar with time estimation */
 class ProgressBar: public QThread, public ProgressBarQt
 {
-public:
-	ProgressBar(std::string a = "ProgressBar");
-	/** simple destructor */
-	virtual ~ProgressBar();
-	virtual void run();
-private:
+  public:
+    ProgressBar ( std::string a = "ProgressBar" );
+    /** simple destructor */
+    virtual ~ProgressBar();
+    virtual void run();
+  private:
 
 };
 

+ 128 - 128
baselib/ProgressBarQt.cpp

@@ -1,4 +1,4 @@
-/** 
+/**
  * @file ProgressBarQt.cpp
  * @brief Show a Progress-Bar with time estimation
  * @author Michael Koch
@@ -24,174 +24,174 @@ using namespace std;
 
 using namespace NICE;
 
-ProgressBarQt::ProgressBarQt(const std::string & _name, bool _useGraphics)
-	: useGraphics (_useGraphics)
+ProgressBarQt::ProgressBarQt ( const std::string & _name, bool _useGraphics )
+    : useGraphics ( _useGraphics )
 {
-	name = _name;
-	step = 0;
-
-	display_on = false;
-	working = true;
-	if (graphicIsAvailable())
-	{
-		if (qApp == NULL)
-		{
-			QtFramework::instance();
-		}
-
-		dialogwindow = new QWidget;
-
-		progressdialog = new QProgressDialog("Process at work ...", "Cancel",
-				0, 100);
-		layout = new QGridLayout(dialogwindow, 1, 1);
-		layout->addWidget(progressdialog, 0, 0);
-		dialogwindow->setLayout(layout);
-	}
-	reset(_name);
+  name = _name;
+  step = 0;
+
+  display_on = false;
+  working = true;
+  if ( graphicIsAvailable() )
+  {
+    if ( qApp == NULL )
+    {
+      QtFramework::instance();
+    }
+
+    dialogwindow = new QWidget;
+
+    progressdialog = new QProgressDialog ( "Process at work ...", "Cancel",
+                                           0, 100 );
+    layout = new QGridLayout ( dialogwindow, 1, 1 );
+    layout->addWidget ( progressdialog, 0, 0 );
+    dialogwindow->setLayout ( layout );
+  }
+  reset ( _name );
 }
 
 ProgressBarQt::~ProgressBarQt()
 {
 }
 
-void ProgressBarQt::timediff2str(char *text, long time)
+void ProgressBarQt::timediff2str ( char *text, long time )
 {
-	int seconds;
-	int minutes;
-	int hours;
-	int milliseconds;
-
-	milliseconds = time % 100;
-	time /= 100;
-	seconds = time % 60;
-	time /= 60;
-	minutes = time % 60;
-	time /= 60;
-	hours = time;
-
-	if (hours != 0)
-	{
-		sprintf(text, "%dh %dm %d.%d s", hours, minutes, seconds, milliseconds);
-	}
-	else if (minutes != 0)
-	{
-		sprintf(text, "%dm %d.%d s", minutes, seconds, milliseconds);
-	}
-	else
-	{
-		sprintf(text, "%d.%d s", seconds, milliseconds);
-	}
+  int seconds;
+  int minutes;
+  int hours;
+  int milliseconds;
+
+  milliseconds = time % 100;
+  time /= 100;
+  seconds = time % 60;
+  time /= 60;
+  minutes = time % 60;
+  time /= 60;
+  hours = time;
+
+  if ( hours != 0 )
+  {
+    sprintf ( text, "%dh %dm %d.%d s", hours, minutes, seconds, milliseconds );
+  }
+  else if ( minutes != 0 )
+  {
+    sprintf ( text, "%dm %d.%d s", minutes, seconds, milliseconds );
+  }
+  else
+  {
+    sprintf ( text, "%d.%d s", seconds, milliseconds );
+  }
 }
 
-void ProgressBarQt::displayTimeStat(int posy, char *text, long time)
+void ProgressBarQt::displayTimeStat ( int posy, char *text, long time )
 {
-	// Text (char *str,int x0,int y0,int val,int exp,Image img);
-	char disptext[200];
-	char timetext[200];
+  // Text (char *str,int x0,int y0,int val,int exp,Image img);
+  char disptext[200];
+  char timetext[200];
 
-	timediff2str(timetext, time);
-	sprintf(disptext, "%s %s", text, timetext);
+  timediff2str ( timetext, time );
+  sprintf ( disptext, "%s %s", text, timetext );
 
 }
 
 double ProgressBarQt::getCurrentTime()
 {
-	struct timeval curtime;
+  struct timeval curtime;
 
-	gettimeofday(&curtime, NULL);
+  gettimeofday ( &curtime, NULL );
 
-	return curtime.tv_sec * 100.0 + curtime.tv_usec / 10000.0;
+  return curtime.tv_sec * 100.0 + curtime.tv_usec / 10000.0;
 }
 
 void ProgressBarQt::show()
 {
-	if (!display_on)
-	{
-		display_on = true;
-	}
-	if (graphicIsAvailable())
-	{
-		if (qApp == NULL)
-		{
-			QtFramework::instance();
-		}
-		dialogwindow->show();
-	}
+  if ( !display_on )
+  {
+    display_on = true;
+  }
+  if ( graphicIsAvailable() )
+  {
+    if ( qApp == NULL )
+    {
+      QtFramework::instance();
+    }
+    dialogwindow->show();
+  }
 }
 
 void ProgressBarQt::hide()
 {
 
-	if (display_on)
-	{
-		//		Show ( OFF, display, name );
-		display_on = false;
-	}
-	if (graphicIsAvailable())
-	{
-		dialogwindow->hide();
-	}
+  if ( display_on )
+  {
+    //  Show ( OFF, display, name );
+    display_on = false;
+  }
+  if ( graphicIsAvailable() )
+  {
+    dialogwindow->hide();
+  }
 }
 
 void ProgressBarQt::stop()
 {
 
-	working = false;
+  working = false;
 }
 
-void ProgressBarQt::reset(const std::string & _name)
+void ProgressBarQt::reset ( const std::string & _name )
 {
-	name = _name;
-	step = 0;
-	elapsed_time = 0;
-	avg_time_step = 0;
-	start_time = getCurrentTime();
+  name = _name;
+  step = 0;
+  elapsed_time = 0;
+  avg_time_step = 0;
+  start_time = getCurrentTime();
 }
 
-void ProgressBarQt::update(int count)
+void ProgressBarQt::update ( int count )
 {
-	step++;
-
-	double progress = step / (double) count;
-
-	elapsed_time = getCurrentTime() - start_time;
-	avg_time_step = elapsed_time / step;
-	estimated_time = (count - step) * avg_time_step;
-
-	size_t mod;
-	if (avg_time_step > 50.0)
-		mod = 1;
-	else
-		mod = (size_t) (50.0 / avg_time_step) + 1;
-
-	if ((mod <= 1) || (step % mod == 0))
-	{
-		char percent_text[10];
-		sprintf(percent_text, "%4.2f %%", step * 100.0 / count);
-
-		displayTimeStat(0, "Elapsed Time : ", (long int) elapsed_time);
-		displayTimeStat(1, "Estimated Time : ", (long int) estimated_time);
-		displayTimeStat(2, "Avg. Time per step : ", (long int) avg_time_step);
-
-		char eltime[200];
-		char estime[200];
-		char avgtime[200];
-		timediff2str(eltime, (long int) elapsed_time);
-		timediff2str(estime, (long int) estimated_time);
-		timediff2str(avgtime, (long int) avg_time_step);
-		fprintf(
-				stderr,
-				"[PROGRESS] %s %s (elapsed time %s, estimated time %s, avg %s), \n",
-				name.c_str(), percent_text, eltime, estime, avgtime);
-		//set progress value.
-		if (graphicIsAvailable())
-		{
-			progressdialog->setValue(progress * 100);
-		}
-	}
+  step++;
+
+  double progress = step / ( double ) count;
+
+  elapsed_time = getCurrentTime() - start_time;
+  avg_time_step = elapsed_time / step;
+  estimated_time = ( count - step ) * avg_time_step;
+
+  size_t mod;
+  if ( avg_time_step > 50.0 )
+    mod = 1;
+  else
+    mod = ( size_t ) ( 50.0 / avg_time_step ) + 1;
+
+  if ( ( mod <= 1 ) || ( step % mod == 0 ) )
+  {
+    char percent_text[10];
+    sprintf ( percent_text, "%4.2f %%", step * 100.0 / count );
+
+    displayTimeStat ( 0, "Elapsed Time : ", ( long int ) elapsed_time );
+    displayTimeStat ( 1, "Estimated Time : ", ( long int ) estimated_time );
+    displayTimeStat ( 2, "Avg. Time per step : ", ( long int ) avg_time_step );
+
+    char eltime[200];
+    char estime[200];
+    char avgtime[200];
+    timediff2str ( eltime, ( long int ) elapsed_time );
+    timediff2str ( estime, ( long int ) estimated_time );
+    timediff2str ( avgtime, ( long int ) avg_time_step );
+    fprintf (
+      stderr,
+      "[PROGRESS] %s %s (elapsed time %s, estimated time %s, avg %s), \n",
+      name.c_str(), percent_text, eltime, estime, avgtime );
+    //set progress value.
+    if ( graphicIsAvailable() )
+    {
+      progressdialog->setValue ( progress * 100 );
+    }
+  }
 }
 
 bool ProgressBarQt::graphicIsAvailable()
 {
-	return (useGraphics && (getenv("DISPLAY") != NULL));
+  return ( useGraphics && ( getenv ( "DISPLAY" ) != NULL ) );
 }

+ 44 - 44
baselib/ProgressBarQt.h

@@ -1,4 +1,4 @@
-/** 
+/**
  * @file ProgressBarQt.h
  * @brief Show a Progress-Bar with time estimation
  * @author Michael Koch
@@ -20,66 +20,66 @@ namespace OBJREC {
 class ProgressBarQt
 {
 
-protected:
+  protected:
 
-	QGridLayout* layout;
-	QWidget* dialogwindow;
-	QProgressDialog* progressdialog;
+    QGridLayout* layout;
+    QWidget* dialogwindow;
+    QProgressDialog* progressdialog;
 
 
-	NICE::Image display;
-	bool display_on;
-	bool working;
-	double start_time;
-	double avg_time_step;
-	double elapsed_time;
-	double estimated_time;
+    NICE::Image display;
+    bool display_on;
+    bool working;
+    double start_time;
+    double avg_time_step;
+    double elapsed_time;
+    double estimated_time;
 
-	int step;
+    int step;
 
-	int bar_width;
-	int bar_height;
-	int bar_top;
-	int bar_borderx;
+    int bar_width;
+    int bar_height;
+    int bar_top;
+    int bar_borderx;
 
-	int text_top;
-	int text_height;
+    int text_top;
+    int text_height;
 
-	std::string name;
+    std::string name;
 
-	bool useGraphics;
+    bool useGraphics;
 
-	void timediff2str(char *text, long time);
-	void displayTimeStat(int posy, char *text, long time);
-	double getCurrentTime();
-	bool graphicIsAvailable();
+    void timediff2str ( char *text, long time );
+    void displayTimeStat ( int posy, char *text, long time );
+    double getCurrentTime();
+    bool graphicIsAvailable();
 
-public:
+  public:
 
-	/** constructor 
-	 @param name name of the operation
-	 */
-	ProgressBarQt(const std::string & name, bool useGraphics = true);
+    /** constructor
+     @param name name of the operation
+     */
+    ProgressBarQt ( const std::string & name, bool useGraphics = true );
 
-	/** simple destructor */
-	virtual ~ProgressBarQt();
+    /** simple destructor */
+    virtual ~ProgressBarQt();
 
-	/** reset the progress bar and the corresponding
-	 name of the operation */
+    /** reset the progress bar and the corresponding
+     name of the operation */
 
-	void reset(const std::string & name);
+    void reset ( const std::string & name );
 
-	/** show the progress bar */
-	void show();
-	/** hide the progress bar */
-	void hide();
+    /** show the progress bar */
+    void show();
+    /** hide the progress bar */
+    void hide();
 
-	void stop();
+    void stop();
 
-	/** update the progress bar
-	 @param count number of total steps of this operation
-	 */
-	void update(int count);
+    /** update the progress bar
+     @param count number of total steps of this operation
+     */
+    void update ( int count );
 
 };
 } // namespace

+ 225 - 225
cbaselib/CachedExample.cpp

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file CachedExample.cpp
 * @brief data caching
 * @author Erik Rodner
@@ -23,292 +23,292 @@ using namespace NICE;
 
 void CachedExample::init ()
 {
-    dchannels = new MultiChannelImageT<double> [D_NUMCHANNELS];
-    ichannels = new MultiChannelImageT<int> [I_NUMCHANNELS];
-    lchannels = new MultiChannelImageT<long> [L_NUMCHANNELS];
-
-    svmap = new SparseVector *[SVNUMCHANNELS];
-    svmap_xsize = new int [SVNUMCHANNELS];
-    svmap_ysize = new int [SVNUMCHANNELS];
-    for ( uint k = 0 ; k < SVNUMCHANNELS ; k++ )
-    {
-	svmap[k] = NULL;
-	svmap_xsize[k] = 0;
-	svmap_ysize[k] = 0;
-    }
+  dchannels = new MultiChannelImageT<double> [D_NUMCHANNELS];
+  ichannels = new MultiChannelImageT<int> [I_NUMCHANNELS];
+  lchannels = new MultiChannelImageT<long> [L_NUMCHANNELS];
+
+  svmap = new SparseVector *[SVNUMCHANNELS];
+  svmap_xsize = new int [SVNUMCHANNELS];
+  svmap_ysize = new int [SVNUMCHANNELS];
+  for ( uint k = 0 ; k < SVNUMCHANNELS ; k++ )
+  {
+    svmap[k] = NULL;
+    svmap_xsize[k] = 0;
+    svmap_ysize[k] = 0;
+  }
+}
+
+CachedExample::CachedExample ( const std::string & _imgfn,
+                               int _newWidth,
+                               int _newHeight )
+{
+  imgfn = _imgfn;
+  newWidth = _newWidth;
+  newHeight = _newHeight;
+  Preprocess::getImageSize ( _imgfn, oxsize, oysize );
+  init();
+  hasColorInformation = true;
 }
 
-CachedExample::CachedExample( const std::string & _imgfn,
-			      int _newWidth,
-			      int _newHeight )
+CachedExample::CachedExample ( const NICE::Image & _img )
 {
-    imgfn = _imgfn;
-    newWidth = _newWidth;
-    newHeight = _newHeight;
-    Preprocess::getImageSize ( _imgfn, oxsize, oysize );
-    init();
-    hasColorInformation = true;
+  imgfn = "";
+  newWidth = -1;
+  newHeight = -1;
+  init();
+
+  oxsize = _img.width();
+  oysize = _img.height();
+  int *gray = new int [ oxsize*oysize ];
+  int k = 0;
+  for ( int y = 0 ; y < oysize ; y++ )
+    for ( int x = 0 ; x < oxsize ; x++, k++ )
+      gray[k] = _img.getPixel ( x, y );
+
+  ichannels[I_GRAYVALUES].reInit ( oxsize, oysize, 1, false );
+  ichannels[I_GRAYVALUES].setImage ( gray, oxsize, oysize, 0 );
+
+  hasColorInformation = false;
 }
 
-CachedExample::CachedExample( const NICE::Image & _img )
+CachedExample::CachedExample ( const NICE::ColorImage & img, bool disableGrayConversion )
 {
-    imgfn = "";
-    newWidth = -1;
-    newHeight = -1;
-    init();
-
-    oxsize = _img.width();
-    oysize = _img.height();
-    int *gray = new int [ oxsize*oysize ];
+  imgfn = "";
+  oxsize = img.width();
+  oysize = img.height();
+  newWidth = -1;
+  newHeight = -1;
+  init();
+
+  if ( ! disableGrayConversion )
+  {
+    // refactor-nice.pl: check this substitution
+    // old: Image imggray;
+    NICE::Image imggray;
+    ICETools::calcGrayImage ( img, imggray );
+
+    ichannels[I_GRAYVALUES].reInit ( oxsize, oysize, 1, true );
+    int *gray = ichannels[I_GRAYVALUES].data[0];
     int k = 0;
     for ( int y = 0 ; y < oysize ; y++ )
-	for ( int x = 0 ; x < oxsize ; x++,k++ )
-	    gray[k] = _img.getPixel(x,y);
+      for ( int x = 0 ; x < oxsize ; x++, k++ )
+        // refactor-nice.pl: check this substitution
+        // old: gray[k] = GetVal(imggray,x,y);
+        gray[k] = imggray.getPixel ( x, y );
+  }
 
-    ichannels[I_GRAYVALUES].reInit ( oxsize, oysize, 1, false );
-    ichannels[I_GRAYVALUES].setImage ( gray, oxsize, oysize, 0 );
+  ichannels[I_COLOR].reInit ( oxsize, oysize, 3, true );
 
-    hasColorInformation = false;
-}
-
-CachedExample::CachedExample( const NICE::ColorImage & img, bool disableGrayConversion )
-{
-    imgfn = "";
-    oxsize = img.width();
-    oysize = img.height();
-    newWidth = -1;
-    newHeight = -1;
-    init();
-
-    if ( ! disableGrayConversion )
+  long int k = 0;
+  for ( int y = 0 ; y < oysize ; y++ )
+    for ( int x = 0 ; x < oxsize ; x++, k++ )
     {
-	// refactor-nice.pl: check this substitution
-	// old: Image imggray;
-	NICE::Image imggray;
-	ICETools::calcGrayImage ( img, imggray );
-
-	ichannels[I_GRAYVALUES].reInit ( oxsize, oysize, 1, true );
-	int *gray = ichannels[I_GRAYVALUES].data[0];
-	int k = 0;
-	for ( int y = 0 ; y < oysize ; y++ )
-	    for ( int x = 0 ; x < oxsize ; x++,k++ )
-		// refactor-nice.pl: check this substitution
-		// old: gray[k] = GetVal(imggray,x,y);
-		gray[k] = imggray.getPixel(x,y);
+      // refactor-nice.pl: check this substitution
+      // old: ichannels[I_COLOR].data[0][k] = GetVal(img.RedImage(), x, y);
+      ichannels[I_COLOR].data[0][k] = img.getPixel ( x, y, 0 );
+      // refactor-nice.pl: check this substitution
+      // old: ichannels[I_COLOR].data[1][k] = GetVal(img.GreenImage(), x, y);
+      ichannels[I_COLOR].data[1][k] = img.getPixel ( x, y, 1 );
+      // refactor-nice.pl: check this substitution
+      // old: ichannels[I_COLOR].data[2][k] = GetVal(img.BlueImage(), x, y);
+      ichannels[I_COLOR].data[2][k] = img.getPixel ( x, y, 2 );
     }
 
-    ichannels[I_COLOR].reInit ( oxsize, oysize, 3, true );
-
-    long int k = 0;
-    for ( int y = 0 ; y < oysize ; y++ )
-	for ( int x = 0 ; x < oxsize ; x++,k++ )
-	{
-	    // refactor-nice.pl: check this substitution
-	    // old: ichannels[I_COLOR].data[0][k] = GetVal(img.RedImage(), x, y);
-	    ichannels[I_COLOR].data[0][k] = img.getPixel(x,y,0);
-	    // refactor-nice.pl: check this substitution
-	    // old: ichannels[I_COLOR].data[1][k] = GetVal(img.GreenImage(), x, y);
-	    ichannels[I_COLOR].data[1][k] = img.getPixel(x,y,1);
-	    // refactor-nice.pl: check this substitution
-	    // old: ichannels[I_COLOR].data[2][k] = GetVal(img.BlueImage(), x, y);
-	    ichannels[I_COLOR].data[2][k] = img.getPixel(x,y,2);
-	}
-
-    hasColorInformation = true;
+  hasColorInformation = true;
 }
-	
+
 CachedExample::~CachedExample()
 {
-    delete [] dchannels;
-    delete [] ichannels;
-    delete [] lchannels;
-
-    for ( uint k = 0 ; k < SVNUMCHANNELS ; k++ )
-	if ( svmap[k] != NULL )
-	    delete [] (svmap[k]);
-
-    delete [] svmap;
-    delete [] svmap_xsize;
-    delete [] svmap_ysize;
-
-    // remove all temporary files
-    for ( map<int, string>::const_iterator j = dtemps.begin();
-					   j != dtemps.end();
-					   j++ )
-    {
-	//fprintf (stderr, "CachedExample: removing temp file %s\n", j->second.c_str() );
-	FileMgt::deleteTempFile ( j->second );
-    }
-    
-    for ( map<int, string>::const_iterator j = itemps.begin();
-					   j != itemps.end();
-					   j++ )
-    {
-	//fprintf (stderr, "CachedExample: removing temp file %s\n", j->second.c_str() );
-	FileMgt::deleteTempFile ( j->second );
-    }
-
-    for ( map<int, string>::const_iterator j = ltemps.begin();
-					   j != ltemps.end();
-					   j++ )
-    {
-	//fprintf (stderr, "CachedExample: removing temp file %s\n", j->second.c_str() );
-	FileMgt::deleteTempFile ( j->second );
-    }
+  delete [] dchannels;
+  delete [] ichannels;
+  delete [] lchannels;
+
+  for ( uint k = 0 ; k < SVNUMCHANNELS ; k++ )
+    if ( svmap[k] != NULL )
+      delete [] ( svmap[k] );
+
+  delete [] svmap;
+  delete [] svmap_xsize;
+  delete [] svmap_ysize;
+
+  // remove all temporary files
+  for ( map<int, string>::const_iterator j = dtemps.begin();
+        j != dtemps.end();
+        j++ )
+  {
+    //fprintf (stderr, "CachedExample: removing temp file %s\n", j->second.c_str() );
+    FileMgt::deleteTempFile ( j->second );
+  }
+
+  for ( map<int, string>::const_iterator j = itemps.begin();
+        j != itemps.end();
+        j++ )
+  {
+    //fprintf (stderr, "CachedExample: removing temp file %s\n", j->second.c_str() );
+    FileMgt::deleteTempFile ( j->second );
+  }
+
+  for ( map<int, string>::const_iterator j = ltemps.begin();
+        j != ltemps.end();
+        j++ )
+  {
+    //fprintf (stderr, "CachedExample: removing temp file %s\n", j->second.c_str() );
+    FileMgt::deleteTempFile ( j->second );
+  }
 
 }
 
 void CachedExample::readImageData ()
 {
-    if ( imgfn == "" ) return;
+  if ( imgfn == "" ) return;
 
-    NICE::Image orig = Preprocess::ReadImgAdv(imgfn);
-    NICE::Image imggray;
+  NICE::Image orig = Preprocess::ReadImgAdv ( imgfn );
+  NICE::Image imggray;
 
-    if ( newWidth > 0 )
-	Conversions::resizeImage ( orig, imggray, newWidth, newHeight );
-    else
-	imggray = orig;
+  if ( newWidth > 0 )
+    Conversions::resizeImage ( orig, imggray, newWidth, newHeight );
+  else
+    imggray = orig;
 
-    oxsize = imggray.width();
-    oysize = imggray.height();
+  oxsize = imggray.width();
+  oysize = imggray.height();
 
-    ichannels[I_GRAYVALUES].reInit ( oxsize, oysize, 1, true );
-    int *gray = ichannels[I_GRAYVALUES].data[0];
-    int k = 0;
-    for ( int y = 0 ; y < oysize ; y++ )
-	for ( int x = 0 ; x < oxsize ; x++,k++ )
-	    gray[k] = imggray.getPixel(x,y);
+  ichannels[I_GRAYVALUES].reInit ( oxsize, oysize, 1, true );
+  int *gray = ichannels[I_GRAYVALUES].data[0];
+  int k = 0;
+  for ( int y = 0 ; y < oysize ; y++ )
+    for ( int x = 0 ; x < oxsize ; x++, k++ )
+      gray[k] = imggray.getPixel ( x, y );
 }
 
 void CachedExample::readImageDataRGB ()
 {
-    if ( imgfn == "" ) return;
-
-    NICE::ColorImage img;
-    try {
-	img = Preprocess::ReadImgAdvRGB(imgfn);
-    } catch ( NICE::ImageException & ) {
-	fprintf (stderr, "error reading rgb image %s\n", imgfn.c_str());
-	hasColorInformation = false;
-	return;
-    }
+  if ( imgfn == "" ) return;
 
-    oxsize = img.width();
-    oysize = img.height();
+  NICE::ColorImage img;
+  try {
+    img = Preprocess::ReadImgAdvRGB ( imgfn );
+  } catch ( NICE::ImageException & ) {
+    fprintf ( stderr, "error reading rgb image %s\n", imgfn.c_str() );
+    hasColorInformation = false;
+    return;
+  }
 
-    hasColorInformation = true;
-    
-    ichannels[I_COLOR].reInit ( oxsize, oysize, 3, true );
+  oxsize = img.width();
+  oysize = img.height();
 
-    long k = 0;
-    for ( int y = 0 ; y < oysize ; y++ )
-	for ( int x = 0 ; x < oxsize ; x++,k++ )
-	{
-	    ichannels[I_COLOR].data[0][k] = img.getPixel(x,y,0);
-	    ichannels[I_COLOR].data[1][k] = img.getPixel(x,y,1);
-	    ichannels[I_COLOR].data[2][k] = img.getPixel(x,y,2);
-	}
+  hasColorInformation = true;
+
+  ichannels[I_COLOR].reInit ( oxsize, oysize, 3, true );
+
+  long k = 0;
+  for ( int y = 0 ; y < oysize ; y++ )
+    for ( int x = 0 ; x < oxsize ; x++, k++ )
+    {
+      ichannels[I_COLOR].data[0][k] = img.getPixel ( x, y, 0 );
+      ichannels[I_COLOR].data[1][k] = img.getPixel ( x, y, 1 );
+      ichannels[I_COLOR].data[2][k] = img.getPixel ( x, y, 2 );
+    }
 }
 
 void CachedExample::calcIntegralImage ()
 {
-    if (ichannels[I_GRAYVALUES].xsize == 0)
+  if ( ichannels[I_GRAYVALUES].xsize == 0 )
+  {
+    readImageData ();
+    if ( ichannels[I_GRAYVALUES].xsize == 0 )
     {
-	readImageData ();
-	if ( ichannels[I_GRAYVALUES].xsize == 0 )
-	{
-	    fprintf (stderr, "CachedExample::getChannel: unable to recover data channel\n");
-	    exit(-1);
-	}
+      fprintf ( stderr, "CachedExample::getChannel: unable to recover data channel\n" );
+      exit ( -1 );
     }
+  }
 
-    lchannels[L_INTEGRALIMAGE].reInit ( ichannels[I_GRAYVALUES].xsize,
-					ichannels[I_GRAYVALUES].ysize,
-					1, true );
-    
-		GenericImageTools::calcIntegralImage ( 
-		lchannels[L_INTEGRALIMAGE].data[0], 
-		ichannels[I_GRAYVALUES].data[0], 
-		ichannels[I_GRAYVALUES].xsize, 
-		ichannels[I_GRAYVALUES].ysize );
+  lchannels[L_INTEGRALIMAGE].reInit ( ichannels[I_GRAYVALUES].xsize,
+                                      ichannels[I_GRAYVALUES].ysize,
+                                      1, true );
+
+  GenericImageTools::calcIntegralImage (
+    lchannels[L_INTEGRALIMAGE].data[0],
+    ichannels[I_GRAYVALUES].data[0],
+    ichannels[I_GRAYVALUES].xsize,
+    ichannels[I_GRAYVALUES].ysize );
 
 }
 
-void CachedExample::buildIntegralSV ( int svchannel, 
-				      SparseVector *_map, 
-				      int xsize_s, int ysize_s )
+void CachedExample::buildIntegralSV ( int svchannel,
+                                      SparseVector *_map,
+                                      int xsize_s, int ysize_s )
 {
-    SparseVector *map = _map;
-    svmap[svchannel] = _map;
-    svmap_xsize[svchannel] = xsize_s;
-    svmap_ysize[svchannel] = ysize_s;
+  SparseVector *map = _map;
+  svmap[svchannel] = _map;
+  svmap_xsize[svchannel] = xsize_s;
+  svmap_ysize[svchannel] = ysize_s;
 
-    int k = xsize_s;
-    for ( int y = 1 ; y < ysize_s; y++, k+=xsize_s )
-	map[k].add ( (map[k-xsize_s]) );
+  int k = xsize_s;
+  for ( int y = 1 ; y < ysize_s; y++, k += xsize_s )
+    map[k].add ( ( map[k-xsize_s] ) );
 
-    k = 1;
-    for ( int x = 1 ; x < xsize_s; x++, k++ )
-	map[k].add ( (map[k-1]) );
+  k = 1;
+  for ( int x = 1 ; x < xsize_s; x++, k++ )
+    map[k].add ( ( map[k-1] ) );
 
-    k = xsize_s + 1;
+  k = xsize_s + 1;
 
-    for ( int y = 1 ; y < ysize_s ; y++,k++ )
+  for ( int y = 1 ; y < ysize_s ; y++, k++ )
+  {
+    for ( int x = 1 ; x < xsize_s ; x++, k++ )
     {
-	for ( int x = 1 ; x < xsize_s ; x++,k++ )
-	{
-	    map[k].add ( (map[k-1]) );
-	    map[k].add ( (map[k-xsize_s]) );
-	    map[k].add ( (map[k-xsize_s-1]), -1.0 );
-	}
+      map[k].add ( ( map[k-1] ) );
+      map[k].add ( ( map[k-xsize_s] ) );
+      map[k].add ( ( map[k-xsize_s-1] ), -1.0 );
     }
+  }
 }
 
-void CachedExample::setSVMap ( int svchannel, 
-			      SparseVector *_map, 
-			      int xsize_s, int ysize_s )
+void CachedExample::setSVMap ( int svchannel,
+                               SparseVector *_map,
+                               int xsize_s, int ysize_s )
 {
-    svmap[svchannel] = _map;
-    svmap_xsize[svchannel] = xsize_s;
-    svmap_ysize[svchannel] = ysize_s;
+  svmap[svchannel] = _map;
+  svmap_xsize[svchannel] = xsize_s;
+  svmap_ysize[svchannel] = ysize_s;
 }
 
 SparseVector *CachedExample::getSVMap ( int svchannel,
-				        int & _xsize, int & _ysize,
-				        int & _tm_xsize, int & _tm_ysize ) const
+                                        int & _xsize, int & _ysize,
+                                        int & _tm_xsize, int & _tm_ysize ) const
 {
-    _xsize = oxsize;
-    _ysize = oysize;
-    _tm_xsize = svmap_xsize[svchannel];
-    _tm_ysize = svmap_ysize[svchannel];
-    assert ( svmap[svchannel] != NULL );
-    return svmap[svchannel];
+  _xsize = oxsize;
+  _ysize = oysize;
+  _tm_xsize = svmap_xsize[svchannel];
+  _tm_ysize = svmap_ysize[svchannel];
+  assert ( svmap[svchannel] != NULL );
+  return svmap[svchannel];
 }
 
 bool CachedExample::colorInformationAvailable() const
 {
-    if ( hasColorInformation ) return true;
-    else {
-	if ( imgfn.size() == 0 ) return false;
-
-	int tmp_xsize, tmp_ysize, tmp_maxval, tmp_nr;
-	// refactor: InfImgFile ( imgfn, tmp_xsize, tmp_ysize, tmp_maxval, tmp_nr );
-	ImageFile imgf ( imgfn );
-	const ImageFile::Header & imgfheader = imgf.getHeader();
-	tmp_xsize = imgfheader.width;
-	tmp_ysize = imgfheader.height;
-	tmp_maxval = 255;
-	tmp_nr = imgfheader.channel;
-
-	if ( tmp_nr > 1 ) return true;
-	else return false;
-    }
+  if ( hasColorInformation ) return true;
+  else {
+    if ( imgfn.size() == 0 ) return false;
+
+    int tmp_xsize, tmp_ysize, tmp_maxval, tmp_nr;
+    // refactor: InfImgFile ( imgfn, tmp_xsize, tmp_ysize, tmp_maxval, tmp_nr );
+    ImageFile imgf ( imgfn );
+    const ImageFile::Header & imgfheader = imgf.getHeader();
+    tmp_xsize = imgfheader.width;
+    tmp_ysize = imgfheader.height;
+    tmp_maxval = 255;
+    tmp_nr = imgfheader.channel;
+
+    if ( tmp_nr > 1 ) return true;
+    else return false;
+  }
 }
 
 void CachedExample::dropPreCached()
 {
-    dropImages<double> ( dchannels, dtemps, D_NUMCHANNELS );
-    dropImages<int> ( ichannels, itemps, I_NUMCHANNELS );
-    dropImages<long> ( lchannels, ltemps, L_NUMCHANNELS );
+  dropImages<double> ( dchannels, dtemps, D_NUMCHANNELS );
+  dropImages<int> ( ichannels, itemps, I_NUMCHANNELS );
+  dropImages<long> ( lchannels, ltemps, L_NUMCHANNELS );
 }

+ 1 - 1
classifier/vclassifier/VCDTSVM.cpp

@@ -4,7 +4,7 @@
 
 #include "core/basics/StringTools.h"
 
-#define WRITE
+#undef WRITE
 
 using namespace OBJREC;