Fawkes API  Fawkes Development Version
siftpp.h
1 
2 /***************************************************************************
3  * siftpp.h - Feature-based classifier using siftpp
4  *
5  * Created: Sat Apr 12 10:15:23 2008
6  * Copyright 2008 Stefan Schiffer [stefanschiffer.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef _FIREVISION_CLASSIFIERS_SIFTPP_H_
25 #define _FIREVISION_CLASSIFIERS_SIFTPP_H_
26 
27 #ifndef HAVE_SIFTPP
28 # error SIFTPP not available, you may not use the SiftppClassifier
29 #endif
30 
31 #include <fvclassifiers/classifier.h>
32 #include <utils/time/clock.h>
33 #include <utils/time/tracker.h>
34 
35 #include <vector>
36 
37 // FIXME replace with forward declarations
38 #include <siftpp/sift.hpp>
39 
40 //#ifdef SIFTPP_TIMETRACKER
41 
43 //#endif
44 
45 namespace firevision {
46 
47 class SiftppClassifier : public Classifier
48 {
49 public:
50  SiftppClassifier(const char *features_file,
51  int samplingStep = 2,
52  int octaves = 4,
53  int levels = 3,
54  float magnif = 3.0,
55  int noorient = 0,
56  int unnormalized = 0);
57 
58  virtual ~SiftppClassifier();
59 
60  virtual std::list<ROI> *classify();
61 
62  /** Siftpp Feature struct. */
63  struct Feature
64  {
65  VL::Sift::Keypoint key; /**< keypoint */
66  int number_of_desc; /**< number of descriptors */
67  VL::float_t ** descs; /**< descriptors */
68  };
69 
70 private:
71  // Find closest interest point in a list, given one interest point
72  int findMatch(const Feature &ip1, const std::vector<Feature> &ipts);
73 
74  // Calculate square distance of two vectors
75  //double distSquare(double *v1, double *v2, int n);
76  double distSquare(VL::float_t *v1, VL::float_t *v2, int n);
77 
78  // Object objects
79  VL::PgmBuffer * obj_img_;
80  std::vector<Feature> obj_features_;
81  int obj_num_features_;
82 
83  // Image objects
84  VL::PgmBuffer * image_;
85  std::vector<Feature> img_features_;
86  int img_num_features_;
87 
88  // Initial sampling step (default 2)
89  int samplingStep_;
90  // Number of analysed octaves (default 4)
91  int octaves_;
92  // Number of levels per octave (default 3)
93  int levels_;
94  // Blob response treshold
95  VL::float_t threshold_;
96  VL::float_t edgeThreshold_;
97 
98  int first_;
99 
100  // float const sigman_;
101  // float const sigma0_;
102  float sigman_;
103  float sigma0_;
104 
105  // Keypoint magnification (default 3)
106  float magnif_;
107  // Upright SIFTPP or rotation invaraiant
108  int noorient_;
109  // Normalize decriptors?
110  int unnormalized_;
111 
112  // UNUSED
113  // int stableorder = 0 ;
114  // int savegss = 0 ;
115  // int verbose = 0 ;
116  // int binary = 0 ;
117  // int haveKeypoints = 0 ;
118  // int fp = 0 ;
119 
120  // Length of descriptor vector
121  int vlen_;
122 
123  //#ifdef SIFTPP_TIMETRACKER
124  fawkes::TimeTracker *tt_;
125  unsigned int loop_count_;
126  unsigned int ttc_objconv_;
127  unsigned int ttc_objfeat_;
128  unsigned int ttc_imgconv_;
129  unsigned int ttc_imgfeat_;
130  unsigned int ttc_matchin_;
131  unsigned int ttc_roimerg_;
132  //#endif
133 };
134 
135 } // end namespace firevision
136 
137 #endif
firevision::Classifier
Definition: classifier.h:39
firevision::SiftppClassifier::~SiftppClassifier
virtual ~SiftppClassifier()
Destructor.
Definition: siftpp.cpp:229
firevision::SiftppClassifier::classify
virtual std::list< ROI > * classify()
Definition: siftpp.cpp:240
firevision::SiftppClassifier::Feature::key
VL::Sift::Keypoint key
keypoint
Definition: siftpp.h:64
firevision::SiftppClassifier::Feature
Siftpp Feature struct.
Definition: siftpp.h:62
firevision::SiftppClassifier::Feature::descs
VL::float_t ** descs
descriptors
Definition: siftpp.h:66
firevision::SiftppClassifier
Definition: siftpp.h:46
fawkes::TimeTracker
Definition: tracker.h:40
firevision::SiftppClassifier::SiftppClassifier
SiftppClassifier(const char *features_file, int samplingStep=2, int octaves=4, int levels=3, float magnif=3.0, int noorient=0, int unnormalized=0)
Constructor.
Definition: siftpp.cpp:68
firevision::SiftppClassifier::Feature::number_of_desc
int number_of_desc
number of descriptors
Definition: siftpp.h:65