is a detailed description of the line fitting function in the OPENCV Official document:
The Fitline () function is used to fit a point set in a two-dimensional or three-dimensional space in a straight line. A total of six parameters:
Param 1: The set of points entered, either Mat or VECTOR<>, which can be either a two-dimensional point set or a three-dimensional point set.
For example:
vector<point> points;
Param 2: Fit the result, i.e. a straight line. In a two-dimensional space, a line can be defined as
vec4f Line;
In a two-dimensional plane, (line[0],line[1]) represents a direction vector for a line, (Line[2],line[3]) that represents a point on a line.
Param 3: The fitting method, the CV_DIST_L2 is the simplest and fastest least squares, the recommended use.
PARAM 4: The value of the parameter C in the fitting method is set to 0, the optimal value is automatically selected.
Param 5 & param 6: Officially recommended 0.01.
OpenCV Fitline Linear fitting function learning