Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "ParallelSurfExtractor.h"
00012
00013
00014 #include <cmath>
00015 #include <sstream>
00016 #include <float.h>
00017
00018
00019
00020 #include "../../Workers/Puma2/ColorToGrayOperator.h"
00021
00022 #include "../../Workers/ParallelSurf/Image.h"
00023 #include "../../Workers/ParallelSurf/KeyPointDetector.h"
00024 #include "../../Workers/ParallelSurf/KeyPointDescriptor.h"
00025 #include "../../Workers/ParallelSurf/KeyPoint.h"
00026
00027 #define THIS ParallelSurfExtractor
00028
00029
00030
00031
00032 THIS::THIS( int numThreads )
00033 {
00034 m_IntegralImage = 0;
00035
00036 if ( numThreads != 0 )
00037 {
00038 m_ThreadPool = new boost::threadpool::pool( numThreads );
00039 }
00040 else
00041 {
00042 m_ThreadPool = new boost::threadpool::pool( boost::thread::hardware_concurrency() );
00043 }
00044 }
00045
00046
00047 THIS::~THIS()
00048 {
00049
00050 delete m_IntegralImage;
00051
00052 }
00053
00054
00055
00056 THIS::THIS ( const THIS& other ) : SurfExtractorBase ( other )
00057 {
00058 }
00059
00060
00061 THIS& THIS::operator= ( const THIS & other )
00062 {
00063 SurfExtractorBase::operator=(other);
00064 return *this;
00065 }
00066
00067
00068
00069 std::string THIS::getName()
00070 {
00071 std::ostringstream s;
00072 s << "ParallelSURF (" << m_ThreadPool->size() << " threads)";
00073 return s.str();
00074 }
00075
00076
00077 void THIS::setImage ( const puma2::GrayLevelImage8 &pumaImage )
00078 {
00079 delete m_IntegralImage;
00080 m_IntegralImage = new parallelsurf::Image( pumaImage.unsafeRowPointerArray(), pumaImage.getWidth(), pumaImage.getHeight() );
00081 }
00082
00083
00084 void THIS::setImage ( const puma2::ColorImageRGB8 &pumaImage )
00085 {
00086 puma2::GrayLevelImage8 pumaImageY;
00087 puma2::ColorToGrayOperator<puma2::ColorImageRGB8,puma2::GrayLevelImage8>( pumaImage, pumaImageY );
00088
00089 delete m_IntegralImage;
00090 m_IntegralImage = new parallelsurf::Image( (const unsigned char**)pumaImageY.unsafeRowPointerArray(), pumaImage.getWidth(), pumaImage.getHeight() );
00091 }
00092
00093
00094 void THIS::getKeyPoints ( std::vector< KeyPoint >& keyPoints )
00095 {
00096
00097 std::vector<parallelsurf::KeyPoint> panoKeyPoints;
00098
00099 parallelsurf::KeyPointDetector detector( *m_IntegralImage, *m_ThreadPool );
00100 parallelsurf::KeyPointDescriptor descriptor( *m_IntegralImage, *m_ThreadPool, m_Extended );
00101
00102
00103 KeyPointVectInsertor insertor( panoKeyPoints );
00104
00105
00106 detector.setMaxOctaves( m_Octaves );
00107 detector.setScoreThreshold( m_BlobResponseThreshold );
00108
00109 detector.detectKeyPoints( insertor );
00110
00111
00112
00113 if ( m_RotationInvariance)
00114 {
00115 descriptor.assignOrientations( panoKeyPoints.begin(), panoKeyPoints.end() );
00116 }
00117 else
00118 {
00119 for ( unsigned i=0; i<panoKeyPoints.size(); i++ )
00120 {
00121 panoKeyPoints[i]._ori=0;
00122 }
00123 }
00124
00125 descriptor.makeDescriptors( panoKeyPoints.begin(), panoKeyPoints.end() );
00126
00127
00128 keyPoints.resize( panoKeyPoints.size() );
00129
00130 for ( unsigned i=0; i<panoKeyPoints.size(); i++ )
00131 {
00132 keyPoints[i].x = panoKeyPoints[i]._x;
00133 keyPoints[i].y = panoKeyPoints[i]._y;
00134 keyPoints[i].scale = panoKeyPoints[i]._scale;
00135 keyPoints[i].orientation = panoKeyPoints[i]._ori;
00136 keyPoints[i].strength = panoKeyPoints[i]._score;
00137 keyPoints[i].sign = panoKeyPoints[i]._trace;
00138 keyPoints[i].featureVector = panoKeyPoints[i]._vec;
00139 }
00140
00141 }
00142