Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

KnowledgeBase.h

Go to the documentation of this file.
00001 #ifndef __KNOWLEDGEBASE_H
00002 #define __KNOWLEDGEBASE_H
00003 
00004 #include <vector>
00005 #include "Hashtable.h"
00006 #include "CharPtrHash.h"
00007 
00008 class model;
00009 class object;
00010 class keypoint;
00011 class keypointPair;
00012 class keygroup;
00013 class matchInfo;
00014 
00015 class KDTree;
00016 
00017 namespace NEWMAT {
00018   class Matrix;
00019 }
00020 
00021 // void getBestHoughTransforms(vector<NEWMAT::Matrix>* transforms, vector<keypoint*> keys, vector<keypoint*> matches, vector<double>* error, vector<vector<keypointPair*>*>* inliersToReturn);
00022 
00023 class KnowledgeBase{
00024 private:
00025   
00026   class modelMatchingInfo{
00027   public:
00028     modelMatchingInfo();
00029     ~modelMatchingInfo();
00030     
00031     model* matchedModel;
00032     NEWMAT::Matrix* solution;
00033     std::vector<keypointPair*>* inliers;
00034     double error, probOfMatch;
00035   private:
00036     modelMatchingInfo(const modelMatchingInfo&); // Do not call
00037     modelMatchingInfo& operator=(const modelMatchingInfo&); // Do not call
00038   };
00039   
00040   
00041   size_t maxNumModels;
00042   std::vector<keypoint*> keys;
00043   std::vector<keygroup*> keygroups;
00044   std::vector<model*>    models;
00045   std::vector<object*>  objects;
00046   KDTree* myTree;
00047   Hashtable<double, CharPtrKey, hashCharPtrKey, CharPtrKeyEquals> paramHash;
00048     
00049   void cleanUpMemory();
00050     
00051   void keypointMatching(std::vector<keypoint*>* newKeys, std::vector< std::vector< std::vector<keypoint*> > >& matches, std::vector< std::vector< std::vector<keypoint*> > >& imageKey, bool objectSpecified, int wantedObjectID);
00052   void modelMatching(size_t numNewKeys, std::vector< std::vector< std::vector<keypoint*> > >& matches, std::vector< std::vector< std::vector<keypoint*> > >& imageKey, std::vector<modelMatchingInfo*>& mminfo/*, vector<model*>& acceptableModels, vector<double>& modelConfidence, vector<double>& modelError, vector<int>& solutionIndex, vector< vector< vector<NEWMAT::Matrix*> > >& solutions, vector< vector< vector< vector<keypointPair*>* > > >& inliers*/);
00053   
00054   void rebuildKDTree();
00055   
00056   object* learn_newObject(std::vector<keypoint*>* newKeys);
00057   object* unlearn_Object(std::vector <keypoint*>* newKeys, int oID);
00058   void    unlearn_fromModel(std::vector<keypoint*>* newKeys, model* bestModel, NEWMAT::Matrix* transform, double& s, double& theta, double& tx, double& ty);    
00059   model*  learn_newModel( std::vector<keypoint*>* newKeys, object* O, std::vector<modelMatchingInfo*> mminfo);
00060   model*  unlearn_Model( std::vector<keypoint*>* newKeys, object* O, std::vector<modelMatchingInfo*> mminfo, int mID);
00061   void    learn_toModel(  std::vector<keypoint*>* newKeys, model* bestModel, NEWMAT::Matrix* transform, double& s, double& theta, double& tx, double& ty);
00062   void    learn_toModel(  std::vector<keypoint*>* newKeys, model* bestModel, NEWMAT::Matrix* transform);
00063   void    unlearn_fromModel(  std::vector<keypoint*>* newKeys, model* bestModel, NEWMAT::Matrix* transform);
00064   object* objectExists(int objectID);
00065   
00066   friend class SiftTekkotsu;
00067   
00068 public:
00069   KnowledgeBase();
00070   ~KnowledgeBase();
00071   
00072   // note: if haveKeys, keypoint* in K are either integrated into KDTree, or are freed by learn
00073   // either way, caller function (no?) need to free key explicitly
00074   //    void learn(string filename, vector<keypoint*>& K, bool haveKeys, bool toIntegrate);
00075   
00076   // If mInfo != NULL, a copy of inliers will be made into mInfo
00077   // caller function must eventually free these inliers
00078   void learn(std::vector<keypoint*>& K, matchInfo& mInfo, bool toIntegrate);
00079   
00080   //    void learnFromFiles(vector<string> filenames, bool toIntegrate);
00081   //    void learnFromFile(string filename, bool toIntegrate);
00082   
00083   
00084   void   setParameter(const char* paramName, double paramVal);
00085   double getParameter(const char* paramName);
00086   
00087   void saveToFile(std::ofstream& outfile);
00088   void readFromFile(std::ifstream& infile);
00089   
00090 private:
00091   KnowledgeBase(const KnowledgeBase&); // Do not call
00092   KnowledgeBase operator=(const KnowledgeBase&); // Do not call
00093   
00094 };
00095 
00096 int getNumParams();
00097 const char* getParamList(int i);
00098 
00099 
00100 #endif

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:42 2016 by Doxygen 1.6.3