OpenCv学習ノート(1)---CvTermCriteria---反復アルゴリズム終了条件構造体の---OpenCVソースコード分析

2747 ワード

/*********************************************************************************************
    :
        1--CvTermCriteria---            ---OpenCV    
		
    :
        OpenCv2.4.8+VS2010
    :
               2016.4.22
    :
          
**********************************************************************************************/
/*********************************** CvTermCriteria *************************************/
//     types_c.h
//【1】CvTermCriteria---(Termination criteria for iterative algorithms)
//【2】         
#define CV_TERMCRIT_ITER    1
#define CV_TERMCRIT_NUMBER  CV_TERMCRIT_ITER
#define CV_TERMCRIT_EPS     2

typedef struct CvTermCriteria
{
	//【1】int type--type of the termination criteria,one of:
	//【1】int type---           ,     :
			//【1】CV_TERMCRIT_ITER---            ,    
			//【2】CV_TERMCRIT_EPS----           double epsilon       ,    
			//【3】CV_TERMCRIT_ITER+CV_TERMCRIT_EPS--           ,     
    int    type;  /* may be combination of
                     CV_TERMCRIT_ITER
                     CV_TERMCRIT_EPS */
	//【2】Maximum number of iterations
	//【2】       
    int    max_iter;
	//【3】Required accuracy
	//【3】       
    double epsilon;
}
CvTermCriteria;
//【2】                ,     ,        
CV_INLINE  CvTermCriteria  cvTermCriteria( int type, int max_iter, double epsilon )
{
    CvTermCriteria t;

    t.type = type;
    t.max_iter = max_iter;
    t.epsilon = (float)epsilon;

    return t;
}
/*********************************************************************************************
*    :
*         --struct CvTermCriteria---          OpenCv2.x        ,     
*     class TermCriteria 
**********************************************************************************************/
/*!
 //          
 Termination criteria in iterative algorithms
 */
class CV_EXPORTS TermCriteria
{
public:
    enum
    {
        COUNT=1, //!< the maximum number of iterations or elements to compute
        MAX_ITER=COUNT, //!< ditto
        EPS=2 //!< the desired accuracy or change in parameters at which the iterative algorithm stops
    };

    //! default constructor
	//【1】      
    TermCriteria();
    //! full constructor
	//【2】      
    TermCriteria(int type, int maxCount, double epsilon);
    //! conversion from CvTermCriteria
	//【3】CvTermCriteria    TermCriteria        
    TermCriteria(const CvTermCriteria& criteria);
    //! conversion to CvTermCriteria
    operator CvTermCriteria() const;
    //【4】TermCriteria        ----       ,      ,      
    int type; //!< the type of termination criteria: COUNT, EPS or COUNT + EPS
    int maxCount; // the maximum number of iterations/elements
    double epsilon; // the desired accuracy
};