
the different available fitting methods. In the case of , the cost function will become the
familiar least-squares fitting procedure that is probably st readers from elementary statistics.
The more complex distan useful when m methods are needed (i.e., fitting
u a or
familiar to mo
ce functions are ore robust fitting
methods that handle o tlier d ta points more gracefully). Table 8-2 shows the available forms f and
ST_L2
the associated OpenCV enum values used by cv::fitLine().
Table 8-2: Available distance metrics for the distType parameter in cv::fitLine()
distType
Distance Metric
Least-squares
method
cv::DI
cv::DIST_L1
cv::DIST_L12
cv::DIST_FAIR
cv::DIST_WELSCH
cv::DIST_HUBER
The OpenCV function cv::fitLine() has the following function prototype:
void cv::fitLine(
cv::InputArray points, // Array 2-dimensional points or vector of
cv::OutputArray line, // Vector of Vec4f (2d), or Vec6f (3d)
int distType, // Distance type (Table 8-2)
double param, // Parameter for distance metric (Table 8-2)
double reps, // Radius accuracy parameter
double aeps // Angle accuracy parameter
);
The argument points is mostly what you have come to expect, a representation of a set of points either
a cv::Mat array or an STL vector. One very important difference, however, between
as
c
t,
r
his
cv::fitLine() matically select the optim e for
r
v::fitLine()
al valu
and ...