1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 08:13:04 +04:00

imgproc: fix fitLine() implementation

- update optimal solutions on each iteration
This commit is contained in:
Alexander Alekhin
2019-10-03 20:45:43 +00:00
parent a105f56957
commit c69245da1f
3 changed files with 51 additions and 5 deletions
+15 -4
View File
@@ -408,8 +408,14 @@ static void fitLine2D( const Point2f * points, int count, int dist,
}
/* calculate distances */
err = calcDist2D( points, count, _line, r );
if( err < EPS )
break;
if (err < min_err)
{
min_err = err;
memcpy(line, _line, 4 * sizeof(line[0]));
if (err < EPS)
break;
}
/* calculate weights */
if( calc_weights )
@@ -550,8 +556,13 @@ static void fitLine3D( Point3f * points, int count, int dist,
}
/* calculate distances */
err = calcDist3D( points, count, _line, r );
//if( err < FLT_EPSILON*count )
// break;
if (err < min_err)
{
min_err = err;
memcpy(line, _line, 6 * sizeof(line[0]));
if (err < EPS)
break;
}
/* calculate weights */
if( calc_weights )