Bjoern Froehlich 13 years ago
parent
commit
d6b1b4bec3

+ 25 - 25
features/localfeatures/LocalFeatureOpponnentSift.cpp

@@ -7,7 +7,7 @@ using namespace OBJREC;
 using namespace std;
 using namespace NICE;
 
-LocalFeatureOpponnentSift::LocalFeatureOpponnentSift( const Config *conf ):LocalFeatureRGBSift(conf)
+LocalFeatureOpponnentSift::LocalFeatureOpponnentSift ( const Config *conf ) : LocalFeatureRGBSift ( conf )
 {
 }
 
@@ -15,29 +15,29 @@ LocalFeatureOpponnentSift::~LocalFeatureOpponnentSift()
 {
 }
 
-int LocalFeatureOpponnentSift::getDescriptors ( const NICE::ColorImage & cimg, 
-		VVector & positions,
-  VVector & descriptors ) const
+int LocalFeatureOpponnentSift::getDescriptors ( const NICE::ColorImage & cimg,
+    VVector & positions,
+    VVector & descriptors ) const
 {
-	NICE::ColorImage opimg(cimg.width(), cimg.height());
-	
-	for(int y = 0; y < (int)cimg.height(); y++)
-	{
-		for(int x = 0; x < (int)cimg.width(); x++)
-		{
-			// Farbkanaele auslesen
-			int r = cimg.getPixel(x,y,0);
-			int g = cimg.getPixel(x,y,1);
-			int b = cimg.getPixel(x,y,2);
-			
-			// Transformation in den Opponent Farbraum nach Van de Sande
-			int o1 = (int)(((double)(r-g)+255.0)/2.0);
-			int o2 = (int)(((double)(r+g-b)+510.0)/4.0);
-			int o3 = (int)((double)(r+g+b)/3.0);
-
-			opimg.setPixel(x,y,o1,o2,o3);
-		}
-	}
-	
-	return LocalFeatureRGBSift::getDescriptors(opimg, positions, descriptors);
+  NICE::ColorImage opimg ( cimg.width(), cimg.height() );
+
+  for ( int y = 0; y < ( int ) cimg.height(); y++ )
+  {
+    for ( int x = 0; x < ( int ) cimg.width(); x++ )
+    {
+      // Farbkanaele auslesen
+      int r = cimg.getPixel ( x, y, 0 );
+      int g = cimg.getPixel ( x, y, 1 );
+      int b = cimg.getPixel ( x, y, 2 );
+
+      // Transformation in den Opponent Farbraum nach Van de Sande
+      int o1 = ( int ) ( ( ( double ) ( r - g ) + 255.0 ) / 2.0 );
+      int o2 = ( int ) ( ( ( double ) ( r + g - b ) + 510.0 ) / 4.0 );
+      int o3 = ( int ) ( ( double ) ( r + g + b ) / 3.0 );
+
+      opimg.setPixel ( x, y, o1, o2, o3 );
+    }
+  }
+
+  return LocalFeatureRGBSift::getDescriptors ( opimg, positions, descriptors );
 }

+ 23 - 23
features/localfeatures/LocalFeatureOpponnentSift.h

@@ -19,36 +19,36 @@
 
 namespace OBJREC
 {
-	/** local feature with sift */
+/** local feature with sift */
 
-	class LocalFeatureOpponnentSift : public LocalFeatureRGBSift
-	{
+class LocalFeatureOpponnentSift : public LocalFeatureRGBSift
+{
 
-		protected:
-			int octaves;
-			int levels;
-			bool normalizeFeature;
-			int first_octave;
-			double magnif;
+  protected:
+    int octaves;
+    int levels;
+    bool normalizeFeature;
+    int first_octave;
+    double magnif;
 
-		public:
+  public:
 
-			/** simple constructor */
-			LocalFeatureOpponnentSift(const NICE::Config *conf);
+    /** simple constructor */
+    LocalFeatureOpponnentSift ( const NICE::Config *conf );
 
-			/** simple destructor */
+    /** simple destructor */
 
-			virtual ~LocalFeatureOpponnentSift();
+    virtual ~LocalFeatureOpponnentSift();
 
-			/**
-			 * get the descriptor
-			 * @param img input image
-			 * @param positions positions for the SIFT features
-			 * @param descriptors output
-			 * @return 0
-			 */
-			int getDescriptors(const NICE::ColorImage & cimg, NICE::VVector & positions, NICE::VVector & descriptors) const;
-	};
+    /**
+     * get the descriptor
+     * @param img input image
+     * @param positions positions for the SIFT features
+     * @param descriptors output
+     * @return 0
+     */
+    int getDescriptors ( const NICE::ColorImage & cimg, NICE::VVector & positions, NICE::VVector & descriptors ) const;
+};
 
 
 } // namespace

+ 38 - 38
features/localfeatures/LocalFeatureRGBSift.cpp

@@ -12,7 +12,7 @@ using namespace std;
 using namespace NICE;
 
 
-LocalFeatureRGBSift::LocalFeatureRGBSift (const Config *conf) : LocalFeatureSift (conf)
+LocalFeatureRGBSift::LocalFeatureRGBSift ( const Config *conf ) : LocalFeatureSift ( conf )
 {
   deletemode = false;
 }
@@ -22,63 +22,63 @@ LocalFeatureRGBSift::~LocalFeatureRGBSift()
 
 }
 
-int 
-LocalFeatureRGBSift::getDescriptors (const NICE::ColorImage & img, VVector & positions, VVector & descriptors) const
+int
+LocalFeatureRGBSift::getDescriptors ( const NICE::ColorImage & img, VVector & positions, VVector & descriptors ) const
 {
-	sortPositions (positions);
-	descriptors.clear();
-	for (int i = 0; i < (int) positions.size(); i++) 
-	{
-		NICE::Vector v;
-		descriptors.push_back (v);
-	}
+  sortPositions ( positions );
+  descriptors.clear();
+  for ( int i = 0; i < ( int ) positions.size(); i++ )
+  {
+    NICE::Vector v;
+    descriptors.push_back ( v );
+  }
 
-	vector<VVector> desc (3);
+  vector<VVector> desc ( 3 );
 
 #ifdef NICE_USELIB_OPENMP
-	// check whether siftGPU should be used
-	int numberOfCPU = omp_get_num_procs();
-	int numberOfThreads = 0;
-	if (isGpuUsed()) 
-	{ 
-		// in case of siftGPU it is possible to use one device
-		numberOfThreads = 1;
-		clog << "[log] LocalFeatureRGBSift: no multithreading" << endl;
-	}
-	else 
-	{
-		// in case of siftpp it is possible to use all given cores
-		numberOfThreads = numberOfCPU;
-		clog << "[log] LocalFeatureRGBSift: multithreading with (max) " << numberOfCPU << " threads" << endl;
-	}
+  // check whether siftGPU should be used
+  int numberOfCPU = omp_get_num_procs();
+  int numberOfThreads = 0;
+  if ( isGpuUsed() )
+  {
+    // in case of siftGPU it is possible to use one device
+    numberOfThreads = 1;
+    clog << "[log] LocalFeatureRGBSift: no multithreading" << endl;
+  }
+  else
+  {
+    // in case of siftpp it is possible to use all given cores
+    numberOfThreads = numberOfCPU;
+    clog << "[log] LocalFeatureRGBSift: multithreading with (max) " << numberOfCPU << " threads" << endl;
+  }
 #endif
 
 #pragma omp parallel for num_threads(numberOfThreads)
-  for (int i = 0; i < 3; i++) {
-    NICE::Image tmp (img.width(), img.height());
+  for ( int i = 0; i < 3; i++ ) {
+    NICE::Image tmp ( img.width(), img.height() );
 
-    for (int y = 0; y < img.height(); y++) {
-      for (int x = 0; x < img.width(); x++) {
-        tmp.setPixel (x, y, img.getPixel (x, y, i));
+    for ( int y = 0; y < img.height(); y++ ) {
+      for ( int x = 0; x < img.width(); x++ ) {
+        tmp.setPixel ( x, y, img.getPixel ( x, y, i ) );
       }
     }
     VVector pos = positions;
-    computeDesc (tmp, pos, desc[i]);
+    computeDesc ( tmp, pos, desc[i] );
   }
 
-  for (int i = 0; i < 3; i++) {
-    assert (desc[i].size() == descriptors.size());
+  for ( int i = 0; i < 3; i++ ) {
+    assert ( desc[i].size() == descriptors.size() );
 
-    if (i == 0) {
+    if ( i == 0 ) {
 #pragma omp parallel for num_threads( numberOfCPU )
-      for (int j = 0; j < (int) desc[i].size(); j++) {
+      for ( int j = 0; j < ( int ) desc[i].size(); j++ ) {
         descriptors[j] = desc[i][j];
       }
     }
     else {
 #pragma omp parallel for num_threads( numberOfCPU )
-      for (int j = 0; j < (int) desc[i].size(); j++) {
-        descriptors[j].append (desc[i][j]);
+      for ( int j = 0; j < ( int ) desc[i].size(); j++ ) {
+        descriptors[j].append ( desc[i][j] );
       }
     }
   }

+ 35 - 33
features/localfeatures/LocalFeatureRGBSift.h

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file LocalFeatureRGBSift.h
 * @brief local feature with color sift
 * @author Björn Fröhlich
@@ -21,38 +21,40 @@ namespace OBJREC {
 class LocalFeatureRGBSift : public LocalFeatureSift
 {
 
-    protected:
-	int octaves;
-	int levels;
-	bool normalizeFeature;
-	int first_octave;
-	double magnif;
-
-    public:
-  
-	/** simple constructor */
-	LocalFeatureRGBSift ( const NICE::Config *conf );
-      
-	/** simple destructor */
-
-	virtual ~LocalFeatureRGBSift();
-	
-	/**
-	 * returns the size of each the SIFT-Feature
-	 * @return 128
-	 */
-	int getDescSize() const { return 384; };
-	
-	/** 
-	 * get the descriptor
-	 * @param img input color image
-	 * @param positions positions for the SIFT features
-	 * @param descriptors output
-	 * @return 0
-	 */
-	virtual int getDescriptors ( const NICE::ColorImage & cimg, 
-			     NICE::VVector & positions,
-			     NICE::VVector & descriptors ) const;     
+  protected:
+    int octaves;
+    int levels;
+    bool normalizeFeature;
+    int first_octave;
+    double magnif;
+
+  public:
+
+    /** simple constructor */
+    LocalFeatureRGBSift ( const NICE::Config *conf );
+
+    /** simple destructor */
+
+    virtual ~LocalFeatureRGBSift();
+
+    /**
+     * returns the size of each the SIFT-Feature
+     * @return 128
+     */
+    int getDescSize() const {
+      return 384;
+    };
+
+    /**
+     * get the descriptor
+     * @param img input color image
+     * @param positions positions for the SIFT features
+     * @param descriptors output
+     * @return 0
+     */
+    virtual int getDescriptors ( const NICE::ColorImage & cimg,
+                                 NICE::VVector & positions,
+                                 NICE::VVector & descriptors ) const;
 };
 
 

+ 19 - 19
features/localfeatures/LocalFeatureSift.h

@@ -4,13 +4,13 @@
 * @author Erik Rodner
 * @date 03/10/2012 (Eric Bach)
 * @note some notes to the use of siftGPU (added by Eric Bach)
-*		- install cudaSift & siftGPU (see Makefile.config)
-*		- add to libdepend.inc: $(call PKG_DEPEND_EXT, CUDASIFT) to specify: -DNICE_USELIB_CUDASIFT as compilerflag
-*		- add to section [LFSiftPP] use_siftgpu=true (or 'false' to disable the gpu-support)
-*		
-*		If you use the gpu-support just one device is supported until now.
-*		If your device do not support the siftGPU completly the class switch to "normal" sift.
-*		It is possible to compile this class without siftGPU, but then you must not specify the flag: -DNICE_USELIB_CUDASIFT.
+*  - install cudaSift & siftGPU (see Makefile.config)
+*  - add to libdepend.inc: $(call PKG_DEPEND_EXT, CUDASIFT) to specify: -DNICE_USELIB_CUDASIFT as compilerflag
+*  - add to section [LFSiftPP] use_siftgpu=true (or 'false' to disable the gpu-support)
+*
+*  If you use the gpu-support just one device is supported until now.
+*  If your device do not support the siftGPU completly the class switch to "normal" sift.
+*  It is possible to compile this class without siftGPU, but then you must not specify the flag: -DNICE_USELIB_CUDASIFT.
 */
 #ifndef LOCALFEATURESIFTINCLUDE
 #define LOCALFEATURESIFTINCLUDE
@@ -32,8 +32,8 @@
 
 // SiftGPU & GL
 #ifdef NICE_USELIB_CUDASIFT
-	#include <src/SiftGPU.h>
-	#include <GL/gl.h>
+#include <src/SiftGPU.h>
+#include <GL/gl.h>
 #endif
 
 
@@ -42,10 +42,10 @@ namespace OBJREC {
 /** local feature with sift */
 class LocalFeatureSift : public LocalFeature
 {
-private:
+  private:
     const NICE::Config* conf;
 
-protected:
+  protected:
     int octaves;
     int levels;
     bool normalizeFeature;
@@ -60,12 +60,12 @@ protected:
     float threshold;
     float edgeThreshold;
 
-    void withPP( const NICE::Image & img, NICE::VVector & positions, NICE::VVector & descriptors ) const;
+    void withPP ( const NICE::Image & img, NICE::VVector & positions, NICE::VVector & descriptors ) const;
 #ifdef NICE_USELIB_CUDASIFT
-    void withGPU( const NICE::Image & img, NICE::VVector & positions, NICE::VVector & descriptors ) const;
+    void withGPU ( const NICE::Image & img, NICE::VVector & positions, NICE::VVector & descriptors ) const;
 #endif
 
-public:
+  public:
 
     /** simple constructor */
     LocalFeatureSift ( const NICE::Config *conf );
@@ -79,16 +79,16 @@ public:
      * @return 128
      */
     int getDescSize() const {
-        return 128;
+      return 128;
     };
 
 
     //! returns true if gpu is used
     bool isGpuUsed() const {
 #ifdef NICE_USELIB_CUDASIFT
-        return usegpu;
+      return usegpu;
 #else
-		return false;
+      return false;
 #endif
     };
 
@@ -109,13 +109,13 @@ public:
      * @param positions
      * @param descriptors
      */
-    void computeDesc( const NICE::Image & img, NICE::VVector & positions, NICE::VVector & descriptors ) const;
+    void computeDesc ( const NICE::Image & img, NICE::VVector & positions, NICE::VVector & descriptors ) const;
 
     /**
      * sort positions by scales for faster computing of the Keypoint orientation
      * @param positions
      */
-    void sortPositions(NICE::VVector & positions) const;
+    void sortPositions ( NICE::VVector & positions ) const;
 
     void visualizeFeatures ( NICE::Image & mark, const NICE::VVector & positions, size_t color ) const;