ObjRecBOF.H
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef ObjRecBOF_H_DEFINED
00039 #define ObjRecBOF_H_DEFINED
00040
00041 #include "Image/OpenCVUtil.H"
00042 #include "Component/ModelComponent.H"
00043 #include "Component/ModelParam.H"
00044 #include "Image/Image.H"
00045 #include "Image/Pixels.H"
00046 #include "SIFT/Histogram.H"
00047 #include "SIFT/FeatureVector.H"
00048
00049 class ObjRecBOF : public ModelComponent
00050 {
00051 public:
00052
00053 struct Keypoint
00054 {
00055 double x;
00056 double y;
00057 double scale;
00058 double ori;
00059 std::vector<double> fv;
00060 int codeWord;
00061 };
00062
00063 struct Object
00064 {
00065 std::string name;
00066 std::vector<Keypoint> keypoints;
00067 };
00068
00069
00070
00071 ObjRecBOF(OptionManager& mgr,
00072 const std::string& descrName = "ObjRecBOF",
00073 const std::string& tagName = "ObjRecBOF");
00074 ~ObjRecBOF();
00075
00076
00077
00078 void start2();
00079
00080 void train(const Image<PixRGB<byte> > &img, const std::string label);
00081 void train(const std::string &name, int cls);
00082 std::string test(const Image<PixRGB<byte> > &img);
00083
00084 Image<float> extractFeatures(const Image<PixRGB<byte> > &img);
00085
00086 void finalizeTraining();
00087 void finalizeTesting();
00088
00089 void extractCodeWords(const char* dirname);
00090 void getCodeWords(int numCodeWords);
00091 void readCodeWords(const char* filename);
00092 int assignCodeWord(const std::vector<double> &fv);
00093 void assignCodeWords();
00094
00095 void getObjCodeWords(const std::string &name);
00096
00097 void readSaliencyFeatures(const char* dirname);
00098 void getSaliencyKeypoints(const std::string &name);
00099 std::vector<Keypoint> readSaliencyKeypoints(const char *filename);
00100 std::vector<Keypoint> readSIFTKeypoints(const char *filename);
00101 void printCodeWords();
00102 void printAssignedCodeWords();
00103 void printFeatures();
00104
00105
00106 void extractGaborFeatures(const Image<PixRGB<byte> > &img);
00107
00108
00109 void getSIFTKeypoints(const std::string &name);
00110 void extractSIFTFeatures(const Image<PixRGB<byte> > &img);
00111 std::vector<std::vector<byte> > getSiftDescriptor(const Image<float> &lum,
00112 const float x, const float y, const float s);
00113 void calculateOrientationVector(const float x, const float y, const float s,
00114 const Image<float>& gradmag, const Image<float>& gradorie, Histogram& OV);
00115 std::vector<std::vector<byte> > createVectorsAndKeypoints(const float x, const float y, const float s,
00116 const Image<float>& gradmag, const Image<float>& gradorie, Histogram& OV);
00117
00118
00119 void getIlabSIFTKeypoints(const std::string &name);
00120 std::vector<Keypoint> readIlabSIFTKeypoints(const char *filename);
00121
00122
00123 private:
00124 int itsNumOriArray;
00125 std::vector<Object> itsObjects;
00126 std::vector<std::vector<double> > itsCodeWords;
00127
00128
00129 };
00130
00131 #endif
00132
00133
00134
00135
00136
00137