ObjRecSPM.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
00039
00040 #ifndef ObjRecSPM_H_DEFINED
00041 #define ObjRecSPM_H_DEFINED
00042
00043 #include "Component/ModelComponent.H"
00044 #include "Component/ModelParam.H"
00045 #include "Image/Image.H"
00046 #include "Image/ImageSet.H"
00047 #include "Image/Pixels.H"
00048 #include "SIFT/Histogram.H"
00049 #include "Neuro/getSaliency.H"
00050
00051 #include <vector>
00052 #include <limits>
00053
00054 class ObjRecSPM : public ModelComponent
00055 {
00056 public:
00057
00058 struct SiftKeypoint {
00059 int x;
00060 int y;
00061 std::vector<std::vector<byte> > fv;
00062 };
00063
00064 struct Descriptor {
00065 std::vector<std::vector<Histogram> > featureLevelHist;
00066 std::vector<SiftKeypoint> siftDescriptors;
00067 };
00068
00069 struct Object
00070 {
00071 int id;
00072 std::string name;
00073 std::vector<Descriptor> model;
00074 };
00075
00076
00077 ObjRecSPM(OptionManager& mgr,
00078 const std::string& descrName = "ObjRecSPM",
00079 const std::string& tagName = "ObjRecSPM");
00080 ~ObjRecSPM();
00081
00082
00083
00084 void start2();
00085
00086 void train(const Image<PixRGB<byte> > &img, const std::string label);
00087 void finalizeTraining();
00088 std::string predict(const Image<PixRGB<byte> > &img);
00089
00090 Descriptor extractFeatures(const Image<float> &input);
00091 Descriptor extractSiftFeatures(const Image<float> &input);
00092
00093 uint getObject(const std::string name);
00094
00095
00096 int findObject(const Descriptor &desc);
00097
00098 double matchKernel(const std::vector<Histogram>& A, const std::vector<Histogram>& B);
00099
00100 double matchDescriptor(const Descriptor& descA, const Descriptor& descB);
00101
00102
00103 std::vector<std::vector<byte> > getSiftDescriptor(const Image<float> &lum,
00104 const float x, const float y, const float s);
00105 void calculateOrientationVector(const float x, const float y, const float s,
00106 const Image<float>& gradmag, const Image<float>& gradorie, Histogram& OV);
00107 std::vector<std::vector<byte> > createVectorsAndKeypoints(const float x, const float y, const float s,
00108 const Image<float>& gradmag, const Image<float>& gradorie, Histogram& OV);
00109
00110
00111
00112
00113
00114 private:
00115
00116 int itsNumOri;
00117 int itsNumScales;
00118 int itsNumOriArray;
00119 std::vector<Object> itsObjects;
00120
00121 ImageSet<float> itsFilters;
00122
00123 nub::soft_ref<GetSaliency> itsGetSaliency;
00124 bool itsUseSaliency;
00125 };
00126
00127 #endif
00128
00129
00130
00131
00132
00133