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_keypointdetector_h
00025 #define __parallelsurf_keypointdetector_h
00026 
00027 #include "Image.h"
00028 #include "KeyPoint.h"
00029 
00030 #include <boost/thread.hpp>
00031 #include "../ThreadPool/threadpool.hpp"
00032 
00033 namespace parallelsurf
00034 {
00035 
00037 class KeyPointInsertor
00038 {
00039   public:
00040     virtual void operator() ( const KeyPoint &k ) = 0;
00041 };
00042 
00043 class KeyPointDetector
00044 {
00045   public:
00051     KeyPointDetector ( Image& iImage, boost::threadpool::pool &iThreadPool );
00052 
00054     inline void setMaxScales ( int iMaxScales ) { _maxScales = iMaxScales; }
00055 
00057     inline void setMaxOctaves ( int iMaxOctaves ) { _maxOctaves = iMaxOctaves; }
00058 
00060     inline void setScoreThreshold ( double iThreshold ) { _scoreThreshold = iThreshold; }
00061 
00067     void detectKeyPoints ( KeyPointInsertor& iInsertor );
00068 
00069   private:
00070 
00071     int getFilterSize ( int iOctave, int iScale );
00072     int getBorderSize ( int iOctave, int iScale );
00073 
00074     
00075 
00076     
00077     int _maxScales;
00078 
00079     
00080     int _maxOctaves;
00081 
00082     
00083     double _scoreThreshold;
00084 
00085     
00086     int _initialBoxFilterSize;
00087 
00088     
00089     
00090     int _scaleOverlap;
00091 
00092     
00093     const static double kBaseSigma;
00094     
00095     Image &_image;
00096 
00097     boost::threadpool::pool &_threadPool;
00098 
00102     struct ComputeHelper
00103     {
00104       Image& _image;
00105       double ***_scaleHessian;
00106       const int _octave;
00107       const int _octaveWidth;
00108       const int _octaveHeight;
00109       const int _pixelStep;
00110       const int * _borderSize;
00111       const double _scoreThreshold;
00112       const int _initialBoxFilterSize;
00113       const int _maxScales;
00114 
00115       boost::mutex &_insertorMutex;
00116 
00118       void calcDet ( int s, int filterSize );
00119       
00121       void detect ( int s, KeyPointInsertor& iInsertor );
00122 
00124       bool fineTuneExtrema ( double *** iSH, int iX, int iY, int iS,
00125                              double& oX, double& oY, double& oS, double& oScore,
00126                              int iOctaveWidth, int iOctaveHeight, int iBorder );
00127 
00129       bool calcTrace ( Image& iImage, double iX, double iY, double iScale, int& oTrace );
00130     };
00131 
00132 };
00133 
00134 }
00135 
00136 #endif //__parallelsurf_keypointdetector_h