use of georegression.metric.ClosestPoint2D_F32 in project BoofCV by lessthanoptimal.
the class GridRansacLineDetector method convertToLineSegment.
/**
* Lines are found in polar form and this coverts them into line segments by finding
* the extreme points of points on the line.
*
* @param matchSet Set of points belonging to the line.
* @param model Detected line.
* @return Line segement.
*/
private LineSegment2D_F32 convertToLineSegment(List<Edgel> matchSet, LinePolar2D_F32 model) {
float minT = Float.MAX_VALUE;
float maxT = -Float.MAX_VALUE;
LineParametric2D_F32 line = UtilLine2D_F32.convert(model, (LineParametric2D_F32) null);
Point2D_F32 p = new Point2D_F32();
for (Edgel e : matchSet) {
p.set(e.x, e.y);
float t = ClosestPoint2D_F32.closestPointT(line, e);
if (minT > t)
minT = t;
if (maxT < t)
maxT = t;
}
LineSegment2D_F32 segment = new LineSegment2D_F32();
segment.a.x = line.p.x + line.slope.x * minT;
segment.a.y = line.p.y + line.slope.y * minT;
segment.b.x = line.p.x + line.slope.x * maxT;
segment.b.y = line.p.y + line.slope.y * maxT;
return segment;
}
use of georegression.metric.ClosestPoint2D_F32 in project BoofCV by lessthanoptimal.
the class LineImageOps method mergeIntoA.
private static void mergeIntoA(LineSegment2D_F32 a, LineSegment2D_F32 b) {
LineParametric2D_F32 paraA = UtilLine2D_F32.convert(a, (LineParametric2D_F32) null);
Point2D_F32[] pts = new Point2D_F32[4];
float[] t = new float[4];
pts[0] = a.a;
pts[1] = a.b;
pts[2] = b.a;
pts[3] = b.b;
for (int i = 0; i < 4; i++) t[i] = ClosestPoint2D_F32.closestPointT(paraA, pts[i]);
float min = t[0];
float max = min;
int indexMin = 0;
int indexMax = 0;
for (int i = 1; i < 4; i++) {
float v = t[i];
if (v < min) {
min = v;
indexMin = i;
}
if (v > max) {
max = v;
indexMax = i;
}
}
// set the first line to the extreme points on each line
a.a.set(pts[indexMin]);
a.b.set(pts[indexMax]);
}
Aggregations