use of georegression.struct.shapes.Polygon2D_F64 in project BoofCV by lessthanoptimal.
the class TestQrCodeDecoderImage method rotateUntilAt.
@Test
public void rotateUntilAt() {
Polygon2D_F64 square = new Polygon2D_F64(0, 0, 2, 0, 2, 2, 0, 2);
assertTrue(square.isCCW());
Polygon2D_F64 original = square.copy();
QrCodeDecoderImage.rotateUntilAt(square, 0, 0);
assertTrue(square.isIdentical(original, UtilEjml.TEST_F64));
QrCodeDecoderImage.rotateUntilAt(square, 1, 0);
assertTrue(square.isCCW());
assertTrue(square.get(0).distance(2, 0) < UtilEjml.TEST_F64);
QrCodeDecoderImage.rotateUntilAt(square, 0, 1);
assertTrue(square.isIdentical(original, UtilEjml.TEST_F64));
}
use of georegression.struct.shapes.Polygon2D_F64 in project BoofCV by lessthanoptimal.
the class FiducialTrackerDemoApp method processImage.
@Override
public void processImage(int sourceID, long frameID, BufferedImage buffered, ImageBase input) {
detector.detect((I) input);
Graphics2D g2 = buffered.createGraphics();
Se3_F64 targetToSensor = new Se3_F64();
Point2D_F64 center = new Point2D_F64();
Polygon2D_F64 polygon = new Polygon2D_F64();
for (int i = 0; i < detector.totalFound(); i++) {
long id = detector.getId(i);
if (controls.showBoundary) {
detector.getBounds(i, polygon);
g2.setStroke(new BasicStroke(11));
g2.setColor(Color.BLUE);
VisualizeShapes.drawPolygon(polygon, true, g2, true);
}
if (controls.showCenter) {
detector.getCenter(i, center);
VisualizeFeatures.drawPoint(g2, center.x, center.y, 10, Color.MAGENTA, true);
}
if (controls.show3D) {
detector.getFiducialToCamera(i, targetToSensor);
double width = detector.getWidth(i);
VisualizeFiducial.drawLabelCenter(targetToSensor, intrinsic, "" + id, g2);
VisualizeFiducial.drawCube(targetToSensor, intrinsic, width, 5, g2);
}
if (controls.showStability) {
handleStability(input.height, g2, i, id);
}
}
imageCopy = ConvertBufferedImage.checkCopy(buffered, imageCopy);
panel.setImageUI(imageCopy);
}
use of georegression.struct.shapes.Polygon2D_F64 in project BoofCV by lessthanoptimal.
the class CommonFitPolygonChecks method renderPolygons.
public void renderPolygons(List<Polygon2D_F64> polygons, Class imageType) {
BufferedImage work = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = work.createGraphics();
g2.setColor(Color.WHITE);
g2.fillRect(0, 0, width, height);
g2.setColor(Color.BLACK);
distorted.clear();
for (int i = 0; i < polygons.size(); i++) {
Polygon2D_F64 orig = polygons.get(i);
int[] x = new int[orig.size()];
int[] y = new int[orig.size()];
for (int j = 0; j < orig.size(); j++) {
x[j] = (int) orig.get(j).x;
y[j] = (int) orig.get(j).y;
}
g2.fillPolygon(x, y, orig.size());
distorted.add(orig);
}
orig = null;
image = GeneralizedImageOps.createSingleBand(imageType, width, height);
ConvertBufferedImage.convertFrom(work, image, true);
if (showRendered) {
ListDisplayPanel panel = new ListDisplayPanel();
panel.addImage(work, "Work");
panel.addImage(image, "Image");
try {
Thread.sleep(4000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
use of georegression.struct.shapes.Polygon2D_F64 in project BoofCV by lessthanoptimal.
the class CommonFitPolygonChecks method createFromSquare.
protected Polygon2D_F64 createFromSquare(Affine2D_F64 affine) {
Polygon2D_F64 input = new Polygon2D_F64(4);
if (affine != null) {
AffinePointOps_F64.transform(affine, new Point2D_F64(x0, y0), input.get(0));
AffinePointOps_F64.transform(affine, new Point2D_F64(x0, y1), input.get(1));
AffinePointOps_F64.transform(affine, new Point2D_F64(x1, y1), input.get(2));
AffinePointOps_F64.transform(affine, new Point2D_F64(x1, y0), input.get(3));
} else {
input.get(0).set(new Point2D_F64(x0, y0));
input.get(1).set(new Point2D_F64(x0, y1));
input.get(2).set(new Point2D_F64(x1, y1));
input.get(3).set(new Point2D_F64(x1, y0));
}
return input;
}
use of georegression.struct.shapes.Polygon2D_F64 in project BoofCV by lessthanoptimal.
the class TestAdjustPolygonForThresholdBias method adjustForThresholdBias.
@Test
public void adjustForThresholdBias() {
AdjustPolygonForThresholdBias alg = new AdjustPolygonForThresholdBias();
Polygon2D_F64 original = new Polygon2D_F64(10, 10, 10, 40, 35, 40, 35, 10);
Polygon2D_F64 shape = original.copy();
alg.process(shape, true);
assertTrue(shape.get(0).distance(10, 10) <= UtilEjml.EPS);
assertTrue(shape.get(1).distance(10, 41) <= UtilEjml.EPS);
assertTrue(shape.get(2).distance(36, 41) <= UtilEjml.EPS);
assertTrue(shape.get(3).distance(36, 10) <= UtilEjml.EPS);
shape = original.copy();
shape.flip();
alg.process(shape, false);
assertTrue(shape.get(0).distance(10, 10) <= UtilEjml.EPS);
assertTrue(shape.get(3).distance(10, 41) <= UtilEjml.EPS);
assertTrue(shape.get(2).distance(36, 41) <= UtilEjml.EPS);
assertTrue(shape.get(1).distance(36, 10) <= UtilEjml.EPS);
}
Aggregations