1, constructor initialization list:
Cmcurveex::cmcurveex (const mat& srcimg1f, float maxorntdif): M_maxangdif (MAXORNTDIF), m_img1f (srcimg1f)
{
Cv_assert (srcimg1f.type () = = CV_32FC1);
M_h = m_img1f.rows;
M_w = M_img1f.cols;
M_pder1f.create (M_h, M_w, CV_32FC1);
M_pornt1f.create (M_h, M_w, CV_32FC1);
M_plabel1i.create (M_h, M_w, CV_32SC1);
M_pnext1i.create (M_h, M_w, CV_32SC1);
} </span>
In the definition of a class parameter, there is such a definition:
Class Cmcurveex
{public
:
const Mat &m_img1f;//Input image
float m_maxangdif;// Maximum allowable angular difference in a curve
}</span>
This is the initialization list operation when writing the constructor of a class, unlike multiple inheritance of a class, where multiple inheritance of a class is:
Class Name: base Class A, base class B
{
.........
}
The syntax for the constructor initialization list is this:
Constructor (): Class parameter A (initialization value), class parameter B (initialization value)
{
................
}
The constructor initialization list is initialized to class members.
Constructors must be initialized with a list of three scenarios,
1. Data members that need to be initialized are objects (call the base class constructor when inheriting)
2. Class members that require the initialization of the const modifier
3. Require initialization of reference member data
2,cv_assert (srcimg1f.type () = = CV_32FC1);
This is an assertion that, if false in parentheses, throws an error and terminates the program, otherwise it works.