use of georegression.struct.shapes.Rectangle2D_F64 in project BoofCV by lessthanoptimal.
the class TestTldAdjustRegion method process.
@Test
public void process() {
ScaleTranslate2D motion = new ScaleTranslate2D(1.5, 2, 3);
FastQueue<AssociatedPair> pairs = new FastQueue<>(AssociatedPair.class, true);
for (int i = 0; i < 200; i++) {
AssociatedPair p = pairs.grow();
p.p1.x = rand.nextGaussian() * 2;
p.p1.y = rand.nextGaussian() * 2;
p.p2.x = p.p1.x * motion.scale + motion.transX;
p.p2.y = p.p1.y * motion.scale + motion.transY;
}
Rectangle2D_F64 rect = new Rectangle2D_F64(10, 20, 30, 40);
TldAdjustRegion alg = new TldAdjustRegion(30);
alg.init(300, 400);
assertTrue(alg.process(pairs, rect));
assertEquals(17, rect.p0.x, 1e-8);
assertEquals(33, rect.p0.y, 1e-8);
assertEquals(47, rect.p1.x, 1e-8);
assertEquals(63, rect.p1.y, 1e-8);
}
use of georegression.struct.shapes.Rectangle2D_F64 in project BoofCV by lessthanoptimal.
the class CommonFitPolygonChecks method findMatchesOriginal.
/**
* Compare found rectangle against rectangles in the original undistorted image
*/
protected int findMatchesOriginal(Polygon2D_F64 found, double tol) {
int match = 0;
for (int i = 0; i < rectangles.size(); i++) {
Rectangle2D_I32 ri = rectangles.get(i);
Rectangle2D_F64 r = new Rectangle2D_F64(ri.x0, ri.y0, ri.x1, ri.y1);
Polygon2D_F64 p = new Polygon2D_F64(4);
UtilPolygons2D_F64.convert(r, p);
if (p.isCCW())
p.flip();
if (UtilPolygons2D_F64.isEquivalent(found, p, tol))
match++;
}
return match;
}
use of georegression.struct.shapes.Rectangle2D_F64 in project BoofCV by lessthanoptimal.
the class TestEdgeIntensityPolygon method checkIntensity.
@Test
public void checkIntensity() {
GrayU8 image = new GrayU8(400, 500);
int value = 200;
ImageMiscOps.fillRectangle(image, value, 20, 30, 40, 40);
EdgeIntensityPolygon<GrayU8> alg = new EdgeIntensityPolygon<>(2, 2, 10, GrayU8.class);
Polygon2D_F64 polygon = new Polygon2D_F64(4);
UtilPolygons2D_F64.convert(new Rectangle2D_F64(20, 30, 60, 70), polygon);
alg.setImage(image);
assertTrue(alg.computeEdge(polygon, polygon.isCCW()));
assertTrue(alg.checkIntensity(false, 50));
assertFalse(alg.checkIntensity(true, 50));
}
use of georegression.struct.shapes.Rectangle2D_F64 in project BoofCV by lessthanoptimal.
the class TestTldAdjustRegion method adjustRectangle.
@Test
public void adjustRectangle() {
TldAdjustRegion alg = new TldAdjustRegion(50);
Rectangle2D_F64 rect = new Rectangle2D_F64(10, 20, 30, 40);
ScaleTranslate2D motion = new ScaleTranslate2D(1.5, 2, 3);
alg.adjustRectangle(rect, motion);
assertEquals(17, rect.p0.x, 1e-8);
assertEquals(33, rect.p0.y, 1e-8);
assertEquals(47, rect.p1.x, 1e-8);
assertEquals(63, rect.p1.y, 1e-8);
}
use of georegression.struct.shapes.Rectangle2D_F64 in project BoofCV by lessthanoptimal.
the class TestTldHelperFunctions method convertRegion_I32_F32.
@Test
public void convertRegion_I32_F32() {
Rectangle2D_F64 a = new Rectangle2D_F64();
Rectangle2D_I32 b = new Rectangle2D_I32();
b.set(10, 12, 11, 61);
TldHelperFunctions.convertRegion(b, a);
assertEquals(10, a.p0.x, 1e-8);
assertEquals(12, a.p0.y, 1e-8);
assertEquals(11, a.p1.x, 1e-8);
assertEquals(61, a.p1.y, 1e-8);
}
Aggregations