[−][src]Function opencv::imgproc::fit_line
pub fn fit_line(
points: &dyn ToInputArray,
line: &mut dyn ToOutputArray,
dist_type: i32,
param: f64,
reps: f64,
aeps: f64
) -> Result<()>
Fits a line to a 2D or 3D point set.
The function fitLine fits a line to a 2D or 3D point set by minimizing where is a distance between the point, the line and is a distance function, one of the following:
- DIST_L2
- DIST_L1
- DIST_L12
- DIST_FAIR
- DIST_WELSCH
- DIST_HUBER
The algorithm is based on the M-estimator ( http://en.wikipedia.org/wiki/M-estimator ) technique that iteratively fits the line using the weighted least-squares algorithm. After each iteration the weights are adjusted to be inversely proportional to .
Parameters
- points: Input vector of 2D or 3D points, stored in std::vector<> or Mat.
- line: Output line parameters. In case of 2D fitting, it should be a vector of 4 elements (like Vec4f) - (vx, vy, x0, y0), where (vx, vy) is a normalized vector collinear to the line and (x0, y0) is a point on the line. In case of 3D fitting, it should be a vector of 6 elements (like Vec6f) - (vx, vy, vz, x0, y0, z0), where (vx, vy, vz) is a normalized vector collinear to the line and (x0, y0, z0) is a point on the line.
- distType: Distance used by the M-estimator, see #DistanceTypes
- param: Numerical parameter ( C ) for some types of distances. If it is 0, an optimal value is chosen.
- reps: Sufficient accuracy for the radius (distance between the coordinate origin and the line).
- aeps: Sufficient accuracy for the angle. 0.01 would be a good default value for reps and aeps.