use of georegression.struct.shapes.Polygon2D_F64 in project BoofCV by lessthanoptimal.
the class TestDetectPolygonFromContour method checkDetected_LensDistortion.
private void checkDetected_LensDistortion(Class imageType, double tol) {
renderDistortedRectangles(true, imageType);
Affine2D_F32 a = new Affine2D_F32();
UtilAffine.convert(transform, a);
PixelTransform2_F32 tranFrom = new PixelTransformAffine_F32(a);
PixelTransform2_F32 tranTo = new PixelTransformAffine_F32(a.invert(null));
int numberOfSides = 4;
DetectPolygonFromContour alg = createDetector(imageType, numberOfSides, numberOfSides);
alg.setLensDistortion(image.width, image.height, tranTo, tranFrom);
alg.process(image, binary);
FastQueue<DetectPolygonFromContour.Info> found = alg.getFound();
assertEquals(rectangles.size(), found.size);
for (int i = 0; i < found.size; i++) {
Polygon2D_F64 p = found.get(i).polygon;
assertEquals(1, findMatchesOriginal(p, tol));
assertEquals(black, found.get(i).edgeInside, 3);
assertEquals(white, found.get(i).edgeOutside, white * 0.05);
}
}
use of georegression.struct.shapes.Polygon2D_F64 in project BoofCV by lessthanoptimal.
the class TestDetectPolygonFromContour method checkDetectedMulti.
private void checkDetectedMulti(Class imageType, List<Polygon2D_F64> polygons, double tol) {
renderPolygons(polygons, imageType);
DetectPolygonFromContour alg = createDetector(imageType, 3, 4);
alg.process(image, binary);
FastQueue<DetectPolygonFromContour.Info> found = alg.getFound();
assertEquals(polygons.size(), found.size);
for (int i = 0; i < found.size; i++) {
Polygon2D_F64 p = found.get(i).polygon;
assertEquals(1, findMatches(p, tol));
}
}
use of georegression.struct.shapes.Polygon2D_F64 in project BoofCV by lessthanoptimal.
the class TestDetectPolygonFromContour method detect_concave.
/**
* Give it an easy to detect concave shape
*/
@Test
public void detect_concave() {
List<Polygon2D_F64> polygons = new ArrayList<>();
Polygon2D_F64 expected = new Polygon2D_F64(20, 20, 20, 80, 40, 40, 80, 80, 80, 20);
polygons.add(expected);
for (Class imageType : imageTypes) {
renderPolygons(polygons, imageType);
DetectPolygonFromContour alg = createDetector(imageType, 5, 5);
alg.setConvex(false);
alg.process(image, binary);
assertEquals(1, alg.getFound().size());
Polygon2D_F64 found = ((DetectPolygonFromContour.Info) alg.getFound().get(0)).polygon;
assertEquals(1, findMatches(found, 3));
}
}
use of georegression.struct.shapes.Polygon2D_F64 in project BoofCV by lessthanoptimal.
the class TestRefinePolygonToContour method reverseOrder.
@Test
public void reverseOrder() {
RectangleLength2D_I32 rect = new RectangleLength2D_I32(0, 0, 10, 5);
List<Point2D_I32> contour = rectToContour(rect);
GrowQueue_I32 vertexes = computeContourVertexes(rect);
flip(vertexes.data, vertexes.size);
RefinePolygonToContour alg = new RefinePolygonToContour();
Polygon2D_F64 found = new Polygon2D_F64();
alg.process(contour, vertexes, found);
assertTrue(checkPolygon(new double[] { 0, 0, 0, 4, 9, 4, 9, 0 }, found));
}
use of georegression.struct.shapes.Polygon2D_F64 in project BoofCV by lessthanoptimal.
the class TestRefinePolygonToContour method basic.
@Test
public void basic() {
RectangleLength2D_I32 rect = new RectangleLength2D_I32(0, 0, 10, 5);
List<Point2D_I32> contour = rectToContour(rect);
GrowQueue_I32 vertexes = computeContourVertexes(rect);
RefinePolygonToContour alg = new RefinePolygonToContour();
Polygon2D_F64 found = new Polygon2D_F64();
alg.process(contour, vertexes, found);
assertTrue(checkPolygon(new double[] { 0, 0, 9, 0, 9, 4, 0, 4 }, found));
}
Aggregations