OrigSurfExtractor.cpp
Go to the documentation of this file.
00001 /*******************************************************************************
00002  *  OrigSurfExtractor.cpp
00003  *
00004  *  (C) 2008 AG Aktives Sehen <agas@uni-koblenz.de>
00005  *           Universitaet Koblenz-Landau
00006  *
00007  *  $Id: $
00008  *
00009  *******************************************************************************/
00010 
00011 #include "OrigSurfExtractor.h"
00012 
00013 
00014 #include <cmath>
00015 #include <sstream>
00016 #include <float.h>
00017 
00018 #include "Architecture/Config/Config.h"
00019 #include "Architecture/Tracer/Tracer.h"
00020 #include "Architecture/Singleton/Clock.h"
00021 
00022 #include "Workers/Puma2/ColorToGrayOperator.h"
00023 #include "Workers/SimpleTimer/SimpleTimer.h"
00024 
00025 #include <surf/surflib.h>
00026 
00027 
00028 #define THIS OrigSurfExtractor
00029 
00030 #define FULL_DEBUG
00031 
00032 using namespace std;
00033 
00034 
00035 THIS::THIS( )
00036 {
00037   m_IntegralImage = 0;
00038 }
00039 
00040 
00041 THIS::~THIS()
00042 {
00043   TRACE_SYSTEMINFO ( "Deleting member variables.." )
00044   
00045   //TODO
00046   if(m_IntegralImage)
00047   {
00048     delete m_IntegralImage;
00049   }
00050 }
00051 
00052 
00053 
00054 THIS::THIS ( const THIS& other ) : SurfExtractorBase ( other )
00055 {
00056 }
00057 
00058 
00059 THIS& THIS::operator= ( const THIS & other )
00060 {
00061   SurfExtractorBase::operator= ( other );
00062   return *this;
00063 }
00064 
00065 
00066 std::string THIS::getName() {
00067   if ( m_Extended )
00068   {
00069     return "SURF-128";
00070   }
00071   else
00072   {
00073     return "SURF-64";
00074   }
00075 }
00076 
00077 
00078 void THIS::setImage ( const puma2::GrayLevelImage8 &pumaImage )
00079 {
00080   int width = pumaImage.getWidth();
00081   int height = pumaImage.getHeight();
00082   
00083   surf::Image* surfImage = new surf::Image ( width, height );
00084   
00085   double** surfRows = surfImage->getPixels();
00086   unsigned char** pumaRows = const_cast<puma2::GrayLevelImage8&> ( pumaImage ).unsafeRowPointerArray();
00087   
00088   for ( int y = 0; y < height; y++ )
00089   {
00090     unsigned char* pumaRow = pumaRows[y];
00091     double* surfRow = surfRows[y];
00092     for ( int x = 0; x < width; x++ )
00093     {
00094       surfRow[x] = double ( pumaRow[x] ) / 255.0;
00095     }
00096   }
00097   
00098   delete m_IntegralImage;
00099   m_IntegralImage = new surf::Image ( surfImage, false );
00100   
00101   //TODO
00102   delete surfImage;
00103 }
00104 
00105 
00106 void THIS::setImage ( const puma2::ColorImageRGB8 &pumaImage )
00107 {
00108   puma2::GrayLevelImage8 pumaImageY;
00109   puma2::ColorToGrayOperator<puma2::ColorImageRGB8,puma2::GrayLevelImage8>( pumaImage, pumaImageY );
00110   setImage( pumaImageY );
00111 }
00112 
00113 
00114 void THIS::getKeyPoints ( std::vector< KeyPoint >& keyPoints )
00115 {
00116   vector<surf::Ipoint> ipoints;
00117   
00118   if ( !m_IntegralImage )
00119   {
00120     TRACE_ERROR ( "No image was set yet." );
00121     return;
00122   }
00123   
00124   ipoints.reserve ( 1000 );
00125   
00126   // Extract keypoints with Fast Hessian
00127   surf::FastHessian fh ( m_IntegralImage, ipoints, m_BlobResponseThreshold, false, m_InitLobeSize*3, m_SamplingStep, m_Octaves );
00128   fh.getInterestPoints();
00129   
00130   surf::Surf surf ( m_IntegralImage, false, !m_RotationInvariance, m_Extended, m_IndexSize );
00131  
00132   keyPoints.resize( ipoints.size() );
00133   
00134   int descLength = surf.getVectLength();
00135   
00136   for ( unsigned i = 0; i < ipoints.size(); i++ )
00137   {
00138     surf.setIpoint ( &ipoints[i] );
00139     surf.assignOrientation();
00140     surf.makeDescriptor();
00141     
00142     keyPoints[i].x = ipoints[i].x;
00143     keyPoints[i].y = ipoints[i].y;
00144     keyPoints[i].scale = ipoints[i].scale;
00145     keyPoints[i].orientation = ipoints[i].ori;
00146     keyPoints[i].strength = ipoints[i].strength;
00147     keyPoints[i].sign = ipoints[i].laplace;
00148     keyPoints[i].copyDescriptor( ipoints[i].ivec, descLength );
00149   }
00150   
00151   
00152   
00153 }
00154 


or_libs
Author(s): Viktor Seib
autogenerated on Tue Jan 7 2014 11:24:03