Search in sources :

Example 1 with MatrixOfList

use of boofcv.struct.feature.MatrixOfList in project BoofCV by lessthanoptimal.

the class TestConnectLinesGrid method checkConnectNeighbor.

private void checkConnectNeighbor(int x, int y) {
    MatrixOfList<LineSegment2D_F32> grid = new MatrixOfList<>(3, 3);
    grid.get(1, 1).add(new LineSegment2D_F32(0, 0, 2, 3));
    grid.get(x, y).add(new LineSegment2D_F32(2, 3, 4, 6));
    ConnectLinesGrid app = new ConnectLinesGrid(0.1, 1, 1);
    app.process(grid);
    List<LineSegment2D_F32> list = grid.createSingleList();
    assertEquals(1, list.size());
    LineSegment2D_F32 l = list.get(0);
    if (l.a.x == 4) {
        Point2D_F32 temp = l.a;
        l.a = l.b;
        l.b = temp;
    }
    assertEquals(0, l.a.x, 1e-8);
    assertEquals(0, l.a.y, 1e-8);
    assertEquals(4, l.b.x, 1e-8);
    assertEquals(6, l.b.y, 1e-8);
}
Also used : LineSegment2D_F32(georegression.struct.line.LineSegment2D_F32) MatrixOfList(boofcv.struct.feature.MatrixOfList) Point2D_F32(georegression.struct.point.Point2D_F32)

Example 2 with MatrixOfList

use of boofcv.struct.feature.MatrixOfList in project BoofCV by lessthanoptimal.

the class TestConnectLinesGrid method checkParallelTolerance.

/**
 * Makes sure the parallel distance tolerance parameter is correctly set and processed
 */
@Test
public void checkParallelTolerance() {
    MatrixOfList<LineSegment2D_F32> grid = new MatrixOfList<>(1, 1);
    grid.get(0, 0).add(new LineSegment2D_F32(0, 0, 2, 0));
    grid.get(0, 0).add(new LineSegment2D_F32(3, 0, 5, 0));
    // have the tolerance be too tight
    ConnectLinesGrid app = new ConnectLinesGrid(2, 2, 0.1);
    app.process(grid);
    assertEquals(2, grid.createSingleList().size());
    // now make the tolerance broader
    app = new ConnectLinesGrid(2, 2, 1.1);
    app.process(grid);
    assertEquals(1, grid.createSingleList().size());
}
Also used : LineSegment2D_F32(georegression.struct.line.LineSegment2D_F32) MatrixOfList(boofcv.struct.feature.MatrixOfList) Test(org.junit.Test)

Example 3 with MatrixOfList

use of boofcv.struct.feature.MatrixOfList in project BoofCV by lessthanoptimal.

the class TestConnectLinesGrid method checkHalfCircleAngle.

/**
 * Orientation of two lines should be compared using the half circle angle.
 *
 * The test is designed to test that both angles are computed using atan() and compared
 * between 0 and 180 degrees
 */
@Test
public void checkHalfCircleAngle() {
    MatrixOfList<LineSegment2D_F32> grid = new MatrixOfList<>(1, 1);
    grid.get(0, 0).add(new LineSegment2D_F32(0, 0, 0, 2));
    grid.get(0, 0).add(new LineSegment2D_F32(0, 0, 0.001f, -2));
    ConnectLinesGrid app = new ConnectLinesGrid(0.1, 1, 1);
    app.process(grid);
    List<LineSegment2D_F32> list = grid.createSingleList();
    assertEquals(1, list.size());
}
Also used : LineSegment2D_F32(georegression.struct.line.LineSegment2D_F32) MatrixOfList(boofcv.struct.feature.MatrixOfList) Test(org.junit.Test)

Example 4 with MatrixOfList

use of boofcv.struct.feature.MatrixOfList in project BoofCV by lessthanoptimal.

the class TestConnectLinesGrid method checkTangentTolerance.

/**
 * Makes sure the tangent distance tolerance parameter is correctly set and processed
 */
@Test
public void checkTangentTolerance() {
    MatrixOfList<LineSegment2D_F32> grid = new MatrixOfList<>(1, 1);
    grid.get(0, 0).add(new LineSegment2D_F32(0, 0, 2, 0));
    grid.get(0, 0).add(new LineSegment2D_F32(2, 1, 4, 1));
    // have the tolerance be too tight
    ConnectLinesGrid app = new ConnectLinesGrid(2, 0.1, 2);
    app.process(grid);
    assertEquals(2, grid.createSingleList().size());
    // now make the tolerance broader
    app = new ConnectLinesGrid(2, 1.1, 2);
    app.process(grid);
    assertEquals(1, grid.createSingleList().size());
}
Also used : LineSegment2D_F32(georegression.struct.line.LineSegment2D_F32) MatrixOfList(boofcv.struct.feature.MatrixOfList) Test(org.junit.Test)

Example 5 with MatrixOfList

use of boofcv.struct.feature.MatrixOfList in project BoofCV by lessthanoptimal.

the class TestConnectLinesGrid method connectInSameRegion.

/**
 * Very basic check which sees if lines are being connected in the same region
 */
@Test
public void connectInSameRegion() {
    MatrixOfList<LineSegment2D_F32> grid = new MatrixOfList<>(1, 1);
    grid.get(0, 0).add(new LineSegment2D_F32(0, 0, 2, 3));
    grid.get(0, 0).add(new LineSegment2D_F32(2, 3, 4, 6));
    ConnectLinesGrid app = new ConnectLinesGrid(0.1, 1, 1);
    app.process(grid);
    List<LineSegment2D_F32> list = grid.createSingleList();
    assertEquals(1, list.size());
    LineSegment2D_F32 l = list.get(0);
    assertEquals(0, l.a.x, 1e-8);
    assertEquals(0, l.a.y, 1e-8);
    assertEquals(4, l.b.x, 1e-8);
    assertEquals(6, l.b.y, 1e-8);
}
Also used : LineSegment2D_F32(georegression.struct.line.LineSegment2D_F32) MatrixOfList(boofcv.struct.feature.MatrixOfList) Test(org.junit.Test)

Aggregations

MatrixOfList (boofcv.struct.feature.MatrixOfList)6 LineSegment2D_F32 (georegression.struct.line.LineSegment2D_F32)6 Test (org.junit.Test)5 Point2D_F32 (georegression.struct.point.Point2D_F32)1