Search in sources :

Example 6 with Point2D_I32

use of georegression.struct.point.Point2D_I32 in project BoofCV by lessthanoptimal.

the class VisualizeBinaryData method render.

public static void render(List<Contour> contours, Color internal, Color external, double scale, Graphics2D g2) {
    g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    Line2D.Double l = new Line2D.Double();
    g2.setStroke(new BasicStroke(Math.max(1, (float) scale)));
    for (Contour c : contours) {
        if (external != null) {
            g2.setColor(external);
            renderContour(scale, g2, l, c.external);
        }
        if (internal != null) {
            g2.setColor(internal);
            for (List<Point2D_I32> inner : c.internal) {
                renderContour(scale, g2, l, inner);
            }
        }
    }
    if (scale > 4) {
        Color before = g2.getColor();
        g2.setStroke(new BasicStroke(1));
        g2.setColor(Color.LIGHT_GRAY);
        for (Contour c : contours) {
            if (external != null) {
                renderContour(scale, g2, l, c.external);
            }
            if (internal != null) {
                for (List<Point2D_I32> inner : c.internal) {
                    renderContour(scale, g2, l, inner);
                }
            }
        }
        g2.setColor(before);
    }
}
Also used : EdgeContour(boofcv.alg.feature.detect.edge.EdgeContour) Contour(boofcv.alg.filter.binary.Contour) Point2D_I32(georegression.struct.point.Point2D_I32) Line2D(java.awt.geom.Line2D)

Example 7 with Point2D_I32

use of georegression.struct.point.Point2D_I32 in project BoofCV by lessthanoptimal.

the class VisualizeFeatures method drawPoints.

public static void drawPoints(Graphics2D g2, Color color, java.util.List<Point2D_I32> points, int radius) {
    g2.setStroke(new BasicStroke(2));
    int ro = radius + 1;
    int wo = ro * 2 + 1;
    int w = radius * 2 + 1;
    for (Point2D_I32 p : points) {
        g2.setColor(color);
        g2.fillOval(p.x - radius, p.y - radius, w, w);
        g2.setColor(Color.BLACK);
        g2.drawOval(p.x - ro, p.y - ro, wo, wo);
    }
}
Also used : Point2D_I32(georegression.struct.point.Point2D_I32) ScalePoint(boofcv.struct.feature.ScalePoint)

Example 8 with Point2D_I32

use of georegression.struct.point.Point2D_I32 in project BoofCV by lessthanoptimal.

the class VisualizeShapes method drawPolygon.

public static <T extends Point2D_I32> void drawPolygon(List<T> vertexes, boolean loop, double scale, Graphics2D g2) {
    g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    Line2D.Double l = new Line2D.Double();
    for (int i = 0; i < vertexes.size() - 1; i++) {
        Point2D_I32 p0 = vertexes.get(i);
        Point2D_I32 p1 = vertexes.get(i + 1);
        drawLine(g2, l, scale * (p0.x + 0.5), scale * (p0.y + 0.5), scale * (p1.x + 0.5), scale * (p1.y + 0.5));
    }
    if (loop && vertexes.size() > 0) {
        Point2D_I32 p0 = vertexes.get(0);
        Point2D_I32 p1 = vertexes.get(vertexes.size() - 1);
        drawLine(g2, l, scale * (p0.x + 0.5), scale * (p0.y + 0.5), scale * (p1.x + 0.5), scale * (p1.y + 0.5));
    }
}
Also used : Point2D_I32(georegression.struct.point.Point2D_I32) Line2D(java.awt.geom.Line2D)

Example 9 with Point2D_I32

use of georegression.struct.point.Point2D_I32 in project BoofCV by lessthanoptimal.

the class VisualizeShapes method drawPolygon.

/**
 * Draws a polygon
 *
 * @param vertexes List of vertices in the polygon
 * @param loop true if the end points are connected, forming a loop
 * @param g2 Graphics object it's drawn to
 */
public static <T extends Point2D_I32> void drawPolygon(List<T> vertexes, boolean loop, Graphics2D g2) {
    for (int i = 0; i < vertexes.size() - 1; i++) {
        Point2D_I32 p0 = vertexes.get(i);
        Point2D_I32 p1 = vertexes.get(i + 1);
        g2.drawLine(p0.x, p0.y, p1.x, p1.y);
    }
    if (loop && vertexes.size() > 0) {
        Point2D_I32 p0 = vertexes.get(0);
        Point2D_I32 p1 = vertexes.get(vertexes.size() - 1);
        g2.drawLine(p0.x, p0.y, p1.x, p1.y);
    }
}
Also used : Point2D_I32(georegression.struct.point.Point2D_I32)

Example 10 with Point2D_I32

use of georegression.struct.point.Point2D_I32 in project BoofCV by lessthanoptimal.

the class TestDescribeImageDenseSift method checkBorder.

/**
 * Features should not be sampled so that they go over the image border
 */
@Test
public void checkBorder() {
    for (Class type : imageTypes) {
        ImageGray image = GeneralizedImageOps.createSingleBand(type, width, height);
        GImageMiscOps.fillUniform(image, rand, 0, 200);
        DescribeImageDense alg = createAlg(type, 8, 9);
        alg.process(image);
        List<Point2D_I32> locations = alg.getLocations();
        int w = getWidthScaleOfOne();
        int r = w / 2;
        int numCols = (image.width - w) / 8;
        int numRows = (image.height - w) / 9;
        assertEquals(numCols * numRows, locations.size());
        for (Point2D_I32 p : locations) {
            assertTrue(p.x + " " + p.y, p.x >= r && p.x <= width - r);
            assertTrue(p.y >= r && p.y <= height - r);
        }
    }
}
Also used : Point2D_I32(georegression.struct.point.Point2D_I32) ImageGray(boofcv.struct.image.ImageGray) FactoryDescribeImageDense(boofcv.factory.feature.dense.FactoryDescribeImageDense) Test(org.junit.Test)

Aggregations

Point2D_I32 (georegression.struct.point.Point2D_I32)153 Test (org.junit.Test)64 ArrayList (java.util.ArrayList)41 GrowQueue_I32 (org.ddogleg.struct.GrowQueue_I32)21 Point2D_F64 (georegression.struct.point.Point2D_F64)11 EdgeContour (boofcv.alg.feature.detect.edge.EdgeContour)8 GrayF32 (boofcv.struct.image.GrayF32)8 GrayS32 (boofcv.struct.image.GrayS32)7 Contour (boofcv.alg.filter.binary.Contour)6 TupleDesc_F64 (boofcv.struct.feature.TupleDesc_F64)6 GrayU8 (boofcv.struct.image.GrayU8)6 PackedSetsPoint2D_I32 (boofcv.struct.PackedSetsPoint2D_I32)5 RectangleLength2D_I32 (georegression.struct.shapes.RectangleLength2D_I32)5 UtilPoint2D_I32 (georegression.geometry.UtilPoint2D_I32)4 Polygon2D_F64 (georegression.struct.shapes.Polygon2D_F64)4 EdgeSegment (boofcv.alg.feature.detect.edge.EdgeSegment)3 Corner (boofcv.alg.shapes.polyline.splitmerge.PolylineSplitMerge.Corner)3 FactoryDescribeImageDense (boofcv.factory.feature.dense.FactoryDescribeImageDense)3 PointIndex_I32 (boofcv.struct.PointIndex_I32)3 LineGeneral2D_F64 (georegression.struct.line.LineGeneral2D_F64)3