surf.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __FIREVISION_CLASSIFIERS_SURF_H_
00025 #define __FIREVISION_CLASSIFIERS_SURF_H_
00026
00027 #ifndef HAVE_SURF
00028 # error SURF not available, you may not use the SurfClassifier
00029 #endif
00030
00031 #include <vector>
00032
00033 #include <classifiers/classifier.h>
00034
00035
00036 #include <surf/ipoint.h>
00037 #include <surf/image.h>
00038
00039
00040 #include <utils/time/clock.h>
00041 #include <utils/time/tracker.h>
00042
00043
00044 #define OFFLINE_SURF true // offline reading - reading from descriptors folder
00045 #define MIN_MATCH_RATIO 0.05
00046
00047
00048 namespace fawkes {
00049 class TimeTracker;
00050 }
00051
00052
00053
00054
00055
00056 namespace firevision {
00057 #if 0
00058 }
00059 #endif
00060
00061 void saveIpoints(std::string sFileName, const std::vector< surf::Ipoint >& ipts, bool bVerbose, bool bLaplacian, int VLength);
00062
00063 void loadIpoints(std::string sFileName, std::vector< surf::Ipoint >& ipts, bool bVerbose, int&);
00064
00065 class SurfClassifier : public Classifier
00066 {
00067 public:
00068
00069 SurfClassifier( std::string keypoints_descriptor_txt_file,
00070 unsigned int min_match = 5,
00071 float min_match_ratio = MIN_MATCH_RATIO,
00072 int samplingStep = 2,
00073 int octaves = 4,
00074 double thres = 4.0,
00075 bool doubleImageSize = false,
00076 int initLobe = 3,
00077 bool upright = false,
00078 bool extended = false,
00079 int indexSize = 4);
00080
00081
00082 SurfClassifier(const char * image_directory_png_files,
00083 unsigned int min_match = 5,
00084 float min_match_ratio = MIN_MATCH_RATIO,
00085 int samplingStep = 2,
00086 int octaves = 4,
00087 double thres = 4.0,
00088 bool doubleImageSize = false,
00089 int initLobe = 3,
00090 bool upright = false,
00091 bool extended = false,
00092 int indexSize = 4);
00093
00094 virtual ~SurfClassifier();
00095
00096 virtual std::list< ROI > * classify();
00097
00098 private:
00099
00100 unsigned int __num_obj;
00101
00102
00103 int findMatch(const surf::Ipoint& ip1, const std::vector< surf::Ipoint >& ipts);
00104
00105
00106 double distSquare(double *v1, double *v2, int n);
00107
00108
00109 surf::Image *__obj_img;
00110 std::vector<std::vector< surf::Ipoint > > __obj_features;
00111 std::vector<std::string> __obj_names;
00112 int __obj_num_features;
00113
00114
00115 surf::Image *__image;
00116 std::vector< surf::Ipoint > __img_features;
00117 int __img_num_features;
00118
00119
00120 unsigned int __min_match;
00121
00122 float __min_match_ratio;
00123
00124
00125 int __samplingStep;
00126
00127 int __octaves;
00128
00129 double __thres;
00130
00131 bool __doubleImageSize;
00132
00133 int __initLobe;
00134
00135 bool __upright;
00136
00137 bool __extended;
00138
00139 int __indexSize;
00140
00141
00142 int __vlen;
00143
00144
00145 fawkes::TimeTracker *__tt;
00146 unsigned int __loop_count;
00147 unsigned int __ttc_objconv;
00148 unsigned int __ttc_objfeat;
00149 unsigned int __ttc_imgconv;
00150 unsigned int __ttc_imgfeat;
00151 unsigned int __ttc_matchin;
00152 unsigned int __ttc_roimerg;
00153
00154
00155 };
00156
00157 }
00158
00159 #endif