00001 #ifndef __SIFTTEKKOTSU_H
00002 #define __SIFTTEKKOTSU_H
00003
00004 #include "Vision/SIFT/SIFTDatabase/KnowledgeBase.h"
00005 #include "Vision/SIFT/ImageHandling/SIFTImage.h"
00006 #include <vector>
00007 #include <string>
00008
00009 class SIFTImage;
00010 class SiftMatch;
00011
00012 namespace DualCoding {
00013 typedef unsigned char uchar;
00014 template<typename T> class Sketch;
00015 }
00016
00017
00018
00019
00020
00021
00022 class SiftTekkotsu{
00023 private:
00024 KnowledgeBase kb;
00025 std::vector<SIFTImage*> imageDatabase;
00026 public:
00027 SIFTImage testSIFTImage;
00028 private:
00029 int siftImageMaxID;
00030
00031 char** argv, **argvCopy;
00032 int argc;
00033
00034
00035 public:
00036 void detectKeypoints(ImageBuffer buffer, std::vector<keypoint*>& keys, std::vector< std::vector< std::vector<int> > >& gaussianSpace);
00037 private:
00038 void detectKeypoints(std::string PGMFileName, ImageBuffer* buffer,
00039 std::vector<keypoint*>& keys, std::vector< std::vector< std::vector<int> > >& gaussianSpace, bool imageProvided);
00040
00041 public:
00042 void findInImage(ImageBuffer buffer, std::vector<SiftMatch*>& matchesFound, bool objectSpecified, int wantedObjectID);
00043 void findInImage(std::vector<keypoint*>& keys, std::vector<SiftMatch*>& matchesFound, bool objectSpecified, int wantedObjectID);
00044 private:
00045 void clearTestState();
00046
00047 int train_addNewObject(std::vector<keypoint*>& keys);
00048 int train_removeObject(std::vector<keypoint*>& keys, int oID);
00049 int train_addToObject(int objectID, std::vector<keypoint*>& keys, object* wantedObject, SiftMatch& matchFound);
00050 int train_removefromObject(int objectID, std::vector<keypoint*>& keys, object* wantedObject, SiftMatch& matchFound);
00051 int train_addNewModel(int objectID, std::vector<keypoint*>& keys, object* wantedObject);
00052 int train_removeModel(int objectID, std::vector<keypoint*>& keys, object* wantedObject, int mID);
00053 void convertSiftMatchFromModelMatchingInfo(SiftMatch& sMatch, KnowledgeBase::modelMatchingInfo& mminfo);
00054
00055 int convertSiftImageIDToIndex(int siftImageID);
00056
00057 public:
00058 SiftTekkotsu();
00059 ~SiftTekkotsu();
00060
00061
00062
00063
00064
00065 int train_addNewObject(std::string PGMFileName);
00066 int train_addNewObject(std::string PGMFileName, unsigned int& siftImageID);
00067 int train_addNewObject(ImageBuffer buffer);
00068 int train_addNewObject(ImageBuffer buffer, unsigned int& siftImageID);
00069
00070 int train_removeObject(std::string PGMFileName, int oID);
00071 int train_removeObject(std::string PGMFileName, unsigned int& siftImageID, int oID);
00072 int train_removeObject(ImageBuffer buffer, int oID);
00073 int train_removeObject(ImageBuffer buffer, unsigned int& siftImageID, int oID);
00074
00075
00076 int train_addToObject(int objectID, std::string PGMFileName);
00077 int train_addToObject(int objectID, std::string PGMFileName, unsigned int& siftImageID, SiftMatch& matchFound);
00078 int train_addToObject(int objectID, ImageBuffer buffer);
00079 int train_addToObject(int objectID, ImageBuffer buffer, unsigned int& siftImageID, SiftMatch& matchFound);
00080
00081 int train_removefromObject(int objectID, std::string PGMFileName);
00082 int train_removefromObject(int objectID, std::string PGMFileName, unsigned int& siftImageID, SiftMatch& matchFound);
00083 int train_removefromObject(int objectID, ImageBuffer buffer);
00084 int train_removefromObject(int objectID, ImageBuffer buffer, unsigned int& siftImageID, SiftMatch& matchFound);
00085
00086
00087 int train_addNewModel(int objectID, std::string PGMFileName);
00088 int train_addNewModel(int objectID, std::string PGMFileName, unsigned int& siftImageID);
00089 int train_addNewModel(int objectID, ImageBuffer buffer);
00090 int train_addNewModel(int objectID, ImageBuffer buffer, unsigned int& siftImageID);
00091
00092 int train_removeModel(int objectID, std::string PGMFileName, int mID);
00093 int train_removeModel(int objectID, std::string PGMFileName, unsigned int& siftImageID, int mID);
00094 int train_removeModel(int objectID, ImageBuffer buffer, int mID);
00095 int train_removeModel(int objectID, ImageBuffer buffer, unsigned int& siftImageID, int mID);
00096
00097
00098
00099
00100 void findObjectInImage(int objectID, std::string PGMFileName, std::vector<SiftMatch*>& matchesFound);
00101 void findObjectInImage(int objectID, ImageBuffer buffer, std::vector<SiftMatch*>& matchesFound);
00102
00103
00104 void findAllObjectsInImage(std::string PGMFileName, std::vector<SiftMatch*>& matchesFound);
00105 void findAllObjectsInImage(ImageBuffer buffer, std::vector<SiftMatch*>& matchesFound);
00106
00107
00108
00109
00110
00111 bool setObjectName(int objectID, std::string Name);
00112 std::string getObjectName(int objectID);
00113 int getObjectID (std::string Name);
00114
00115
00116 bool setModelName(int objectID, int modelID, std::string Name);
00117 std::string getModelName(int objectID, int modelID);
00118 int getModelID (int objectID, std::string Name);
00119
00120
00121
00122
00123 void setParameter(const char* paramName, double paramVal);
00124 double getParameter(const char* paramName);
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134 void saveToFile(const std::string &filename, bool saveImages);
00135 void loadFile(const std::string &filename);
00136 static ImageBuffer sketchToBuffer(const DualCoding::Sketch<DualCoding::uchar>& sk);
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151 bool trainImage_getImageBuffer( unsigned int siftImageID, ImageBuffer& buffer);
00152 bool trainImage_getGaussianSpace(unsigned int siftImageID, std::vector< std::vector< std::vector<int> > >& gaussianSpace);
00153 bool trainImage_getKeypoints( unsigned int siftImageID, std::vector<keypoint*>& keypoints);
00154
00155
00156
00157 void testImage_getImageBuffer( ImageBuffer& buffer);
00158 void testImage_getGaussianSpace(std::vector< std::vector< std::vector<int> > >& gaussianSpace);
00159 void testImage_getKeypoints( std::vector<keypoint*>& keypoints);
00160
00161
00162 bool loadFile1(const char* filename);
00163
00164 private:
00165 SiftTekkotsu(const SiftTekkotsu&);
00166 SiftTekkotsu& operator=(const SiftTekkotsu&);
00167 };
00168
00169 #endif