use of org.ddogleg.struct.DogArray_B in project BoofCV by lessthanoptimal.
the class TestChessboardPolygonHelper method filterPixelPolygon_border.
@Test
void filterPixelPolygon_border() {
ChessboardPolygonHelper alg = new ChessboardPolygonHelper();
Polygon2D_F64 distorted = new Polygon2D_F64(2);
DogArray_B touches = new DogArray_B();
// test initially with all corners inside
touches.add(false);
touches.add(false);
assertFalse(alg.filterPixelPolygon(null, distorted, touches, true));
distorted.vertexes.resize(3);
touches.add(false);
assertTrue(alg.filterPixelPolygon(null, distorted, touches, true));
distorted.vertexes.resize(3);
touches.add(false);
assertTrue(alg.filterPixelPolygon(null, distorted, touches, true));
// this should pass because more than one corner is inside
for (int i = 0; i < touches.size(); i++) {
touches.set(i, true);
}
for (int i = 0; i < 3; i++) {
touches.set(i, false);
assertTrue(alg.filterPixelPolygon(null, distorted, touches, true));
}
}
use of org.ddogleg.struct.DogArray_B in project BoofCV by lessthanoptimal.
the class TestChessboardPolygonHelper method filterPixelPolygon_AllBorder.
@Test
void filterPixelPolygon_AllBorder() {
ChessboardPolygonHelper alg = new ChessboardPolygonHelper();
Polygon2D_F64 distorted = new Polygon2D_F64(3);
DogArray_B touches = new DogArray_B();
touches.add(false);
touches.add(false);
touches.add(false);
// nothing is actually touching the border, should be valid
assertTrue(alg.filterPixelPolygon(null, distorted, touches, true));
touches.set(0, true);
touches.set(1, true);
touches.set(2, true);
assertFalse(alg.filterPixelPolygon(null, distorted, touches, true));
}
use of org.ddogleg.struct.DogArray_B in project BoofCV by lessthanoptimal.
the class TestDetectChessboardSquarePoints method adjustBeforeOptimize.
@Test
void adjustBeforeOptimize() {
DetectChessboardSquarePoints<GrayU8> alg = new DetectChessboardSquarePoints<>(2, 2, ConfigLength.fixed(0.01), null);
Polygon2D_F64 polygon = new Polygon2D_F64(10, 12, 30, 12, 30, 40, 10, 40);
alg.adjustBeforeOptimize(polygon, new DogArray_B(), false);
assertEquals(8.5, polygon.get(0).x, UtilEjml.TEST_F64);
assertEquals(10.5, polygon.get(0).y, UtilEjml.TEST_F64);
assertEquals(31.5, polygon.get(1).x, UtilEjml.TEST_F64);
assertEquals(10.5, polygon.get(1).y, UtilEjml.TEST_F64);
assertEquals(31.5, polygon.get(2).x, UtilEjml.TEST_F64);
assertEquals(41.5, polygon.get(2).y, UtilEjml.TEST_F64);
assertEquals(8.5, polygon.get(3).x, UtilEjml.TEST_F64);
assertEquals(41.5, polygon.get(3).y, UtilEjml.TEST_F64);
polygon = new Polygon2D_F64(10, 12, 30, 12, 30, 40, 10, 40);
polygon.flip();
alg.adjustBeforeOptimize(polygon, new DogArray_B(), true);
assertEquals(8.5, polygon.get(0).x, UtilEjml.TEST_F64);
assertEquals(10.5, polygon.get(0).y, UtilEjml.TEST_F64);
assertEquals(31.5, polygon.get(3).x, UtilEjml.TEST_F64);
assertEquals(10.5, polygon.get(3).y, UtilEjml.TEST_F64);
assertEquals(31.5, polygon.get(2).x, UtilEjml.TEST_F64);
assertEquals(41.5, polygon.get(2).y, UtilEjml.TEST_F64);
assertEquals(8.5, polygon.get(1).x, UtilEjml.TEST_F64);
assertEquals(41.5, polygon.get(1).y, UtilEjml.TEST_F64);
}
use of org.ddogleg.struct.DogArray_B in project BoofCV by lessthanoptimal.
the class TestDetectChessboardSquarePoints method adjustBeforeOptimize_touchesBorder.
@Test
void adjustBeforeOptimize_touchesBorder() {
DetectChessboardSquarePoints<GrayU8> alg = new DetectChessboardSquarePoints<>(2, 2, ConfigLength.fixed(0.01), null);
DogArray_B touches = new DogArray_B();
touches.add(true);
touches.add(true);
touches.add(false);
touches.add(true);
for (boolean clockwise : new boolean[] { true, false }) {
Polygon2D_F64 polygon = new Polygon2D_F64(10, 12, 30, 12, 30, 40, 10, 40);
if (clockwise)
polygon.flip();
alg.adjustBeforeOptimize(polygon, touches, clockwise);
int[] table = clockwise ? new int[] { 0, 3, 2, 1 } : new int[] { 0, 1, 2, 3 };
assertEquals(10, polygon.get(table[0]).x, UtilEjml.TEST_F64);
assertEquals(12, polygon.get(table[0]).y, UtilEjml.TEST_F64);
assertEquals(31.5, polygon.get(table[1]).x, UtilEjml.TEST_F64);
assertEquals(12, polygon.get(table[1]).y, UtilEjml.TEST_F64);
assertEquals(31.5, polygon.get(table[2]).x, UtilEjml.TEST_F64);
assertEquals(41.5, polygon.get(table[2]).y, UtilEjml.TEST_F64);
assertEquals(10, polygon.get(table[3]).x, UtilEjml.TEST_F64);
assertEquals(41.5, polygon.get(table[3]).y, UtilEjml.TEST_F64);
}
}
use of org.ddogleg.struct.DogArray_B in project BoofCV by lessthanoptimal.
the class TestDetectPolygonFromContour method determineCornersOnBorder.
@Test
void determineCornersOnBorder() {
DetectPolygonFromContour alg = createDetector(GrayU8.class, 4, 4);
alg.imageWidth = width;
alg.imageHeight = height;
Polygon2D_F64 poly = new Polygon2D_F64(0, 0, 10, 0, 10, 10, 0, 10);
DogArray_B corners = new DogArray_B();
alg.determineCornersOnBorder(poly, corners);
assertEquals(4, corners.size());
assertTrue(corners.get(0));
assertTrue(corners.get(1));
assertFalse(corners.get(2));
assertTrue(corners.get(3));
}
Aggregations