KeyPointDescriptor.h
Go to the documentation of this file.
00001 /*
00002 * This file is part of Parallel SURF, which implements the SURF algorithm
00003 * using multi-threading.
00004 *
00005 * Copyright (C) 2010 David Gossow
00006 *
00007 * It is based on the SURF implementation included in Pan-o-matic 0.9.4,
00008 * written by Anael Orlinski.
00009 *
00010 * Parallel SURF is free software; you can redistribute it and/or modify
00011 * it under the terms of the GNU General Public License as published by
00012 * the Free Software Foundation; either version 3 of the License, or
00013 * (at your option) any later version.
00014 *
00015 * Parallel SURF is distributed in the hope that it will be useful,
00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 * GNU General Public License for more details.
00019 *
00020 * You should have received a copy of the GNU General Public License
00021 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00022 */
00023 
00024 #ifndef __parallelsurf_keypointdescriptor_h
00025 #define __parallelsurf_keypointdescriptor_h
00026 
00027 // #include "Image.h"
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; // number of square subregions (1 direction)
00043 
00044     double   _sin;   // sinus of orientation
00045     double   _cos;   // cosinus of orientation
00046 
00047     double***  _cmp;   // descriptor components
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     // disallow stupid things
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     // disallow stupid things
00102     KeyPointDescriptor();
00103     KeyPointDescriptor ( const KeyPointDescriptor& );
00104     KeyPointDescriptor& operator= ( KeyPointDescriptor& ) throw();
00105 
00106     // do the actual descriptor computation
00107     void   createDescriptor ( KeyPointDescriptorContext& iCtx, KeyPoint& ioKeyPoint ) const;
00108 
00109     // orig image info
00110     Image&   _image;
00111 
00112     // info about the descriptor
00113     bool   _extended;   // use parallelsurf64 or parallelsurf128
00114     int    _subRegions;  // number of square subregions. default = 4
00115     int    _vecLen;   // length of the vector. 4 for parallelsurf 64, 8 for parallelsurf 128
00116     double   _magFactor;
00117 
00118     boost::threadpool::pool &_threadPool;
00119 };
00120 
00121 //polar representation of wavelet response (for orientation assignment)
00122 struct response
00123 {
00124   float orientation;
00125   float magnitude;
00126 };
00127 
00128 //compares the orientation of two responses
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 ( &parallelsurf::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 ( &parallelsurf::KeyPointDescriptor::makeDescriptor, this, boost::ref ( *aCurrent ) ) );
00154     aCurrent++;
00155   }
00156   _threadPool.wait();
00157 }
00158 
00159 
00160 #endif //__parallelsurf_keypointdescriptor_h


obj_rec_gui
Author(s): AGAS/agas@uni-koblenz.de
autogenerated on Mon Oct 6 2014 02:53:43