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);
}
}
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);
}
}
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));
}
}
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);
}
}
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);
}
}
}
Aggregations