00001 #ifndef CHAMFER_MATCH_H 00002 #define CHAMFER_MATCH_H 00003 00004 #include <cstdlib> 00005 #include <cmath> 00006 #include <ctime> 00007 #include <iostream> 00008 #include <string> 00009 #include <values.h> 00010 #include "mimasconfig.h" 00011 #include "mimasexception.h" 00012 #include "image.h" 00013 #include "canny.h" 00014 #ifdef HAVE_XALAN 00015 #include "xml_reference.h" 00016 #endif 00017 00018 namespace mimas { 00019 00021 enum angle_type {deg, rad}; 00022 00023 00030 class chamfer_match : public object 00031 { 00032 private: 00033 typedef std::string string; 00034 void paethRotateRadian(image<int> &imagein, image<int> &imageout, float radian); 00035 void invert(image<int> &inimage); 00036 void multiLevelCorrelation(image<int> &edgemap, image<int> &objectedgemap, int levels, int &x, int &y, float &corrval); 00037 void chamfer(image<int> &inimage); 00038 #ifdef HAVE_XALAN 00039 void storeChamferParams( std::ostream &stream ); 00040 void extractChamferParams( xml_reference< XalanElement > &docElement ) throw (mimasexception); 00041 #endif 00042 string name; 00043 float ang1, ang2, angstep; 00044 float mincorr; 00045 int mlevels; 00046 bool chamferModel, sceneAdded, ROI; 00047 canny<int> canny; 00048 image<int> scene, model; 00049 int roi_lx, roi_ly, roi_ux, roi_uy; 00050 bool cannyAutoThres; 00051 float cannyStdDev; 00052 int cannyLowThres, cannyHighThres; 00053 00054 00055 public: 00056 00057 chamfer_match(void); 00058 string getName(void); 00059 void setName( const std::string &n ); 00060 void setSearchAngleRange(float angle1, float angle2, float anglestep, angle_type ang); 00061 void setMultiResLevels(int levels); 00062 void setChamferModel(bool val); 00063 bool getChamferModel(void); 00064 void addScene(image<int> &sceneimage); 00065 void findModel(image<int> &modelimage, int &est_x, int &est_y, float &est_anglerad) throw (mimasexception); 00066 void useROI(bool val); 00067 void setROI(int x1, int y1, int x2, int y2); 00068 void setCannyAutoThres(bool val); 00069 void setCannyStdDev(float val); 00070 void setCannyLowThres(int val); 00071 void setCannyHighThres(int val); 00072 float getMinCorrVal(void); 00073 #ifdef HAVE_XALAN 00074 void saveChamferParameters( const char *fileName ) throw (mimasexception); 00075 void loadChamferParameters( const char *fileName ) throw (mimasexception); 00076 #endif 00077 int track_roi_lx, track_roi_ly, track_roi_ux, track_roi_uy; 00078 00079 bool getCannyAutoThres(void); 00080 float getCannyStdDev(void); 00081 int getCannyLowThres(void); 00082 int getCannyHighThres(void); 00083 int getMultiResLevels(void); 00084 void getSearchAngleRange(float &angle1, float &angle2, float &anglestep); 00085 bool getUseROI(void); 00086 }; 00087 00088 }; 00089 00090 #endif