asmlib-opencv
an ASM(Active Shape Model) implementation by C++ & OpenCV
/media/Data/chenxing/myProj/asmlib-opencv/src/similaritytrans.h
Go to the documentation of this file.
00001 #ifndef SIMILARITYTRANS_H
00002 #define SIMILARITYTRANS_H
00003 
00004 #include "cv.h"
00005 using cv::Mat;
00006 
00007 namespace StatModel {
00008 
00009 class ShapeVec;
00010 
00012 class SimilarityTrans{
00013 public:
00015 
00017     void invTransform(const ShapeVec &src, ShapeVec &dst) const;
00018 
00020 
00022     void transform(const ShapeVec &src, ShapeVec &dst) const;
00023 
00025     void setTransformByAlign(const ShapeVec &x, const ShapeVec &xp);
00026 
00028     void warpImage(const Mat &imgSrc, Mat &imgDst) const;
00029 
00031     void warpImgBack(const Mat &imgSrc, Mat &imgDst, bool useDstSize=false) const;
00032 
00034     double getS() const { return sqrt(a*a+b*b); }
00035 
00036     SimilarityTrans():Xt(0), Yt(0), a(1), b(0){}
00037 
00039     SimilarityTrans operator *(const SimilarityTrans & s2) const {
00040         SimilarityTrans ns;
00041         ns.a = a*s2.a-b*s2.b;
00042         ns.b = s2.a*b+s2.b*a;
00043         ns.Xt = a*s2.Xt - b*s2.Yt + Xt;
00044         ns.Yt = b*s2.Xt + a*s2.Yt + Yt;
00045         return ns;
00046     }
00047 
00049     double Xt;
00051     double Yt;
00052 
00054     double a;
00056     double b;
00057 };
00058 
00059 } // Namespace
00060 #endif // SIMILARITYTRANS_H
 All Classes Namespaces Files Functions Variables Typedefs Defines