www.pudn.com > snake_vc++.rar > snake.h
#ifndef SNAKE_H #define SNAKE_H // OpenCV includes: #ifdef _CH_ #pragma package#endif #ifndef _EiC #include "cv.h" #endif // forwared declarations class QtCvWrapper; //! The snake class implements the snake algorithm /*! * The snake class implements the snake algorithm from the OpenCV library. * cvSnakeImage is called within an iteration until the maximum number of * iteration is reached or the error reaches a certain minimum. * * \param parent is just the connection to the application that makes use of the Snake class * \param inImg represents the initial image for Snake segmentation * * \todo more detailed constructors to set paramaters at creation time * \todo alpha, beta and gamma could be vectors -> make it configurable */ class Snake { public: //! constructor of the snake class Snake(QtCvWrapper* parent, IplImage* inImg); //! destructor virtual ~Snake(void); //! sets the input image for the snake algorithm inline bool setInImg(IplImage* inImg){m_inImg = inImg;}; //! returns the actual input image for snake algorithm inline IplImage* getInImg(){return m_inImg;}; //! returns actual snake image inline IplImage* getSnakeImage(){return m_snakeImg;}; //! initializes a first version of the curve void initSnakeCurve(); //! initialize a special snake curve void initSnakeCurve(CvPoint* pt); //! tries to approximate the contour curve with numIterations IplImage* iterateSnakeCurve(int numIterations, bool showIterations); protected: private: //! parent that sets connection to the "outside" QtCvWrapper* m_parent; IplImage* m_inImg; //! input Image IplImage* m_snakeImg; //! image with the snake included CvTermCriteria m_crit; //! stopping criteria CvPoint* m_snakeCurve; //! curve that represents the snake // some constants float m_alpha; //! Weight of continuity energy, single float or array of length floats, one per each contour point. float m_beta; //! Weight of curvature energy, similar to alpha. float m_gamma; //! Weight of image energy, similar to alpha. CvSize m_winSize; //! Size of neighborhood of every point used to search the minimum (use odd numbers!) int m_numSegments; //! number of segments the snake curve is divided int m_numIteration; //! number of iterations the snake algorithm tries to fit the object }; #endif