siftpp.h

00001
00002 /***************************************************************************
00003  *  siftpp.h - Feature-based classifier using siftpp
00004  *
00005  *  Created: Sat Apr 12 10:15:23 2008
00006  *  Copyright 2008 Stefan Schiffer [stefanschiffer.de]
00007  *
00008  ****************************************************************************/
00009
00010 /*  This program 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 2 of the License, or
00013  *  (at your option) any later version. A runtime exception applies to
00014  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00015  *
00016  *  This program is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *  GNU Library General Public License for more details.
00020  *
00021  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00022  */
00023
00024 #ifndef __FIREVISION_CLASSIFIERS_SIFTPP_H_
00025 #define __FIREVISION_CLASSIFIERS_SIFTPP_H_
00026 
00027 #ifndef HAVE_SIFTPP
00028 #  error SIFTPP not available, you may not use the SiftppClassifier
00029 #endif
00030 
00031 #include <vector>
00032 #include <utils/time/clock.h>
00033 #include <utils/time/tracker.h>
00034
00035 #include <classifiers/classifier.h>
00036
00037 // FIXME replace with forward declarations
00038 #include <siftpp/sift.hpp>
00039
00040 //#ifdef SIFTPP_TIMETRACKER
00041
00042 class fawkes::TimeTracker;
00043 //#endif
00044
00045 class SiftppClassifier : public Classifier
00046 {
00047  public:
00048   SiftppClassifier(const char * features_file,
00049                    int samplingStep = 2,
00050                    int octaves = 4,
00051                    int levels = 3,
00052                    float magnif = 3.0,
00053                    int noorient = 0,
00054                    int unnormalized = 0);
00055
00056   virtual ~SiftppClassifier();
00057
00058   virtual std::list< ROI > * classify();
00059 
00060   /** Siftpp Feature struct. */
00061   struct Feature {
00062     VL::Sift::Keypoint key;    /**< keypoint */
00063     int     number_of_desc;    /**< number of descriptors */
00064     VL::float_t ** descs;      /**< descriptors */
00065   };
00066
00067  private:
00068
00069   // Find closest interest point in a list, given one interest point
00070   int findMatch(const Feature & ip1, const std::vector< Feature > & ipts);
00071
00072   // Calculate square distance of two vectors
00073   //double distSquare(double *v1, double *v2, int n);
00074   double distSquare(VL::float_t *v1, VL::float_t *v2, int n);
00075
00076   // Object objects
00077   VL::PgmBuffer      *__obj_img;
00078   std::vector< Feature > __obj_features;
00079   int __obj_num_features;
00080
00081   // Image objects
00082   VL::PgmBuffer      *__image;
00083   std::vector< Feature > __img_features;
00084   int __img_num_features;
00085
00086   // Initial sampling step (default 2)
00087   int __samplingStep;
00088   // Number of analysed octaves (default 4)
00089   int __octaves;
00090   // Number of levels per octave (default 3)
00091   int __levels;
00092   // Blob response treshold
00093   VL::float_t __threshold;
00094   VL::float_t __edgeThreshold;
00095
00096   int   __first;
00097
00098   //  float const __sigman;
00099   //  float const __sigma0;
00100   float __sigman;
00101   float __sigma0;
00102
00103   // Keypoint magnification (default 3)
00104   float __magnif;
00105   // Upright SIFTPP or rotation invaraiant
00106   int   __noorient;
00107   // Normalize decriptors?
00108   int   __unnormalized;
00109
00110   // UNUSED
00111 //   int    stableorder    = 0 ;
00112 //   int    savegss        = 0 ;
00113 //   int    verbose        = 0 ;
00114 //   int    binary         = 0 ;
00115 //   int    haveKeypoints  = 0 ;
00116 //   int    fp             = 0 ;
00117
00118   // Length of descriptor vector
00119   int __vlen;
00120
00121   //#ifdef SIFTPP_TIMETRACKER
00122   fawkes::TimeTracker *__tt;
00123   unsigned int __loop_count;
00124   unsigned int __ttc_objconv;
00125   unsigned int __ttc_objfeat;
00126   unsigned int __ttc_imgconv;
00127   unsigned int __ttc_imgfeat;
00128   unsigned int __ttc_matchin;
00129   unsigned int __ttc_roimerg;
00130   //#endif
00131
00132 };
00133
00134 #endif