Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 #ifndef __parallelsurf_keypointdescriptor_h
00025 #define __parallelsurf_keypointdescriptor_h
00026 
00027 
00028 
00029 #include "threadpool.hpp"
00030 
00031 namespace parallelsurf
00032 {
00033 class KeyPoint;
00034 class Image;
00035 
00036 class KeyPointDescriptorContext
00037 {
00038   public:
00039     KeyPointDescriptorContext ( int iSubRegions, int iVecLen, double iOrientation );
00040     ~KeyPointDescriptorContext();
00041 
00042     int    _subRegions; 
00043 
00044     double   _sin;   
00045     double   _cos;   
00046 
00047     double***  _cmp;   
00048 
00049     void   placeInIndex ( double iMag1, int iOri1,
00050                           double iMag2, int iOri2, double iUIdx, double iVIdx );
00051 
00052     void   placeInIndex2 ( double iMag1, int iOri1, double iUIdx, double iVIdx );
00053 
00054   private:
00055     
00056     KeyPointDescriptorContext();
00057     KeyPointDescriptorContext ( const KeyPointDescriptorContext& );
00058     KeyPointDescriptorContext& operator= ( KeyPointDescriptorContext& ) throw();
00059 
00060 };
00061 
00062 class KeyPointDescriptor
00063 {
00064   public:
00065 
00072     KeyPointDescriptor ( Image& iImage, boost::threadpool::pool &iThreadPool, bool iExtended = false );
00073 
00075     void assignOrientation ( KeyPoint& ioKeyPoint ) const;
00076 
00082     template< class IteratorT >
00083     void assignOrientations ( IteratorT iBegin, IteratorT iEnd );
00084 
00086     void makeDescriptor ( KeyPoint& ioKeyPoint ) const;
00087 
00093     template< class IteratorT >
00094     void makeDescriptors ( IteratorT iBegin, IteratorT iEnd );
00095 
00097     int getDescriptorLength() const;
00098 
00099   private:
00100 
00101     
00102     KeyPointDescriptor();
00103     KeyPointDescriptor ( const KeyPointDescriptor& );
00104     KeyPointDescriptor& operator= ( KeyPointDescriptor& ) throw();
00105 
00106     
00107     void   createDescriptor ( KeyPointDescriptorContext& iCtx, KeyPoint& ioKeyPoint ) const;
00108 
00109     
00110     Image&   _image;
00111 
00112     
00113     bool   _extended;   
00114     int    _subRegions;  
00115     int    _vecLen;   
00116     double   _magFactor;
00117 
00118     boost::threadpool::pool &_threadPool;
00119 };
00120 
00121 
00122 struct response
00123 {
00124   float orientation;
00125   float magnitude;
00126 };
00127 
00128 
00129 bool operator < ( const response a, const response b );
00130 
00131 }
00132 
00133 
00134 template< class IteratorT >
00135 void parallelsurf::KeyPointDescriptor::assignOrientations ( IteratorT iBegin, IteratorT iEnd )
00136 {
00137   IteratorT aCurrent = iBegin;
00138   while ( aCurrent != iEnd )
00139   {
00140     _threadPool.schedule ( boost::bind ( ¶llelsurf::KeyPointDescriptor::assignOrientation, this, boost::ref ( *aCurrent ) ) );
00141     aCurrent++;
00142   }
00143   _threadPool.wait();
00144 }
00145 
00146 
00147 template< class IteratorT >
00148 void parallelsurf::KeyPointDescriptor::makeDescriptors ( IteratorT iBegin, IteratorT iEnd )
00149 {
00150   IteratorT aCurrent = iBegin;
00151   while ( aCurrent != iEnd )
00152   {
00153     _threadPool.schedule ( boost::bind ( ¶llelsurf::KeyPointDescriptor::makeDescriptor, this, boost::ref ( *aCurrent ) ) );
00154     aCurrent++;
00155   }
00156   _threadPool.wait();
00157 }
00158 
00159 
00160 #endif //__parallelsurf_keypointdescriptor_h