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 void saveIpoints(std::string sFileName, const std::vector< surf::Ipoint >& ipts, bool bVerbose, bool bLaplacian, int VLength);
00057
00058 void loadIpoints(std::string sFileName, std::vector< surf::Ipoint >& ipts, bool bVerbose, int&);
00059
00060 class SurfClassifier : public Classifier
00061 {
00062 public:
00063
00064 SurfClassifier( std::string keypoints_descriptor_txt_file,
00065 unsigned int min_match = 5,
00066 float min_match_ratio = MIN_MATCH_RATIO,
00067 int samplingStep = 2,
00068 int octaves = 4,
00069 double thres = 4.0,
00070 bool doubleImageSize = false,
00071 int initLobe = 3,
00072 bool upright = false,
00073 bool extended = false,
00074 int indexSize = 4);
00075
00076
00077 SurfClassifier(const char * image_directory_png_files,
00078 unsigned int min_match = 5,
00079 float min_match_ratio = MIN_MATCH_RATIO,
00080 int samplingStep = 2,
00081 int octaves = 4,
00082 double thres = 4.0,
00083 bool doubleImageSize = false,
00084 int initLobe = 3,
00085 bool upright = false,
00086 bool extended = false,
00087 int indexSize = 4);
00088
00089 virtual ~SurfClassifier();
00090
00091 virtual std::list< ROI > * classify();
00092
00093 private:
00094
00095 unsigned int __num_obj;
00096
00097
00098 int findMatch(const surf::Ipoint& ip1, const std::vector< surf::Ipoint >& ipts);
00099
00100
00101 double distSquare(double *v1, double *v2, int n);
00102
00103
00104 surf::Image *__obj_img;
00105 std::vector<std::vector< surf::Ipoint > > __obj_features;
00106 std::vector<std::string> __obj_names;
00107 int __obj_num_features;
00108
00109
00110 surf::Image *__image;
00111 std::vector< surf::Ipoint > __img_features;
00112 int __img_num_features;
00113
00114
00115 unsigned int __min_match;
00116
00117 float __min_match_ratio;
00118
00119
00120 int __samplingStep;
00121
00122 int __octaves;
00123
00124 double __thres;
00125
00126 bool __doubleImageSize;
00127
00128 int __initLobe;
00129
00130 bool __upright;
00131
00132 bool __extended;
00133
00134 int __indexSize;
00135
00136
00137 int __vlen;
00138
00139
00140 fawkes::TimeTracker *__tt;
00141 unsigned int __loop_count;
00142 unsigned int __ttc_objconv;
00143 unsigned int __ttc_objfeat;
00144 unsigned int __ttc_imgconv;
00145 unsigned int __ttc_imgfeat;
00146 unsigned int __ttc_matchin;
00147 unsigned int __ttc_roimerg;
00148
00149
00150 };
00151
00152 #endif