asmlib-opencv
an ASM(Active Shape Model) implementation by C++ & OpenCV
|
00001 #ifndef SHAPE_H 00002 #define SHAPE_H 00003 #include <string> 00004 #include <vector> 00005 #include "cv.h" 00006 #include "highgui.h" 00007 #include "shapevec.h" 00008 #include "shapeinfo.h" 00009 using std::string; 00010 using std::vector; 00011 using cv::Point_; 00012 using cv::Mat_; 00013 using cv::Mat; 00014 using cv::imread; 00015 using cv::Size; 00016 00017 namespace StatModel { 00018 00020 class ModelImage 00021 { 00022 protected: 00024 int nMarkPoints; 00025 00027 string hostImageName; 00028 00030 Mat imgdata; 00031 00033 vector< Mat > imgPyramid; 00034 vector< Mat_<double> > imgPyrGrayDeriv; 00035 vector< Mat_<uchar> > imgPyrGray; 00036 00038 bool imgLoaded; 00039 00041 ShapeInfo *shapeInfo; 00042 00043 public: 00045 vector< Point_< int > > points; 00046 00048 ShapeVec shapeVec; 00049 00051 bool loadTrainImage(); 00052 00054 bool loadTrainImage(const Mat &img); 00055 00056 void setShapeInfo(ShapeInfo *si){ shapeInfo = si; } 00057 00058 00060 bool releaseTrainImage(); 00061 00063 00069 Mat_< double > getLocalStruct(int pId, int k, int level, double step); 00070 00072 00080 void getPointsOnNorm(int pId, int k, int level, 00081 vector< Point_< int > > &V, 00082 double step, int pOffset=0); 00083 00085 Mat & getTrainImage(int level=0, bool gray=false); 00086 00088 Mat & getDerivImage(int level){ return imgPyrGrayDeriv[level]; } 00089 00091 inline const string &HostImage() const { return hostImageName; } 00092 00093 void buildFromShapeVec(SimilarityTrans &trans); 00094 00096 void setHostImage( const char * hostImageFilename ) { 00097 hostImageName = hostImageFilename; 00098 } 00099 00101 inline int NPoints() const { return nMarkPoints; } 00102 00104 bool readPTS( const char * filename ); 00105 00107 void initPointsByVector( const vector< cv::Point2i > &V); 00108 00110 Mat show(int level = 0, int pId = -1, bool showInWin = true, int highLight = 0); 00111 00112 ModelImage(); 00113 }; 00114 00115 } // Namespace 00116 #endif // SHAPE_H