Search in sources :

Example 1 with ClosestPoint2D_F32

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;
}
Also used : LineSegment2D_F32(georegression.struct.line.LineSegment2D_F32) Edgel(boofcv.alg.feature.detect.line.gridline.Edgel) Point2D_F32(georegression.struct.point.Point2D_F32) ClosestPoint2D_F32(georegression.metric.ClosestPoint2D_F32) LineParametric2D_F32(georegression.struct.line.LineParametric2D_F32)

Example 2 with ClosestPoint2D_F32

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]);
}
Also used : Point2D_F32(georegression.struct.point.Point2D_F32) ClosestPoint2D_F32(georegression.metric.ClosestPoint2D_F32) LineParametric2D_F32(georegression.struct.line.LineParametric2D_F32)

Aggregations

ClosestPoint2D_F32 (georegression.metric.ClosestPoint2D_F32)2 LineParametric2D_F32 (georegression.struct.line.LineParametric2D_F32)2 Point2D_F32 (georegression.struct.point.Point2D_F32)2 Edgel (boofcv.alg.feature.detect.line.gridline.Edgel)1 LineSegment2D_F32 (georegression.struct.line.LineSegment2D_F32)1