use of georegression.struct.shapes.Quadrilateral_F64 in project BoofCV by lessthanoptimal.
the class RenderSquareBinaryGridFiducial method getOrderedExpectedPoints.
public List<Point2D_F64> getOrderedExpectedPoints(int numRows, int numCols) {
List<Point2D_F64> points = new ArrayList<>();
for (int row = 0; row < numRows; row++) {
for (int col = 0; col < numCols; col++) {
Quadrilateral_F64 q = expectedCorners.get(row * numCols + col);
points.add(q.a);
points.add(q.b);
}
for (int col = 0; col < numCols; col++) {
Quadrilateral_F64 q = expectedCorners.get(row * numCols + col);
points.add(q.d);
points.add(q.c);
}
}
return points;
}
use of georegression.struct.shapes.Quadrilateral_F64 in project BoofCV by lessthanoptimal.
the class TestQuadPoseEstimator method basicTest.
@Test
void basicTest() {
LensDistortionNarrowFOV distortion = createDistortion();
Se3_F64 expectedW2C = new Se3_F64();
expectedW2C.T.setTo(0.1, -0.05, 4);
ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.03, 0, 0, expectedW2C.R);
Quadrilateral_F64 quadPlane = new Quadrilateral_F64(-0.5, 0.5, 0.5, 0.5, 0.5, -0.5, -0.5, -0.5);
Quadrilateral_F64 quadViewed = new Quadrilateral_F64();
project(expectedW2C, quadPlane.a, quadViewed.a);
project(expectedW2C, quadPlane.b, quadViewed.b);
project(expectedW2C, quadPlane.c, quadViewed.c);
project(expectedW2C, quadPlane.d, quadViewed.d);
QuadPoseEstimator alg = new QuadPoseEstimator(1e-8, 200);
alg.setFiducial(-0.5, 0.5, 0.5, 0.5, 0.5, -0.5, -0.5, -0.5);
alg.setLensDistoriton(distortion);
assertTrue(alg.process(quadViewed, false));
Se3_F64 found = alg.getWorldToCamera();
assertTrue(found.T.distance(expectedW2C.T) < 1e-6);
assertTrue(MatrixFeatures_DDRM.isIdentical(found.R, expectedW2C.R, 1e-6));
// project the found fiducials back onto the marker and see if it returns the expected result
Point2D_F64 foundMarker = new Point2D_F64();
Point2D_F64 pixel = new Point2D_F64();
alg.normToPixel.compute(quadViewed.a.x, quadViewed.a.y, pixel);
alg.pixelToMarker(pixel.x, pixel.y, foundMarker);
assertTrue(foundMarker.distance(-0.5, 0.5) < 1e-6);
alg.normToPixel.compute(quadViewed.b.x, quadViewed.b.y, pixel);
alg.pixelToMarker(pixel.x, pixel.y, foundMarker);
assertTrue(foundMarker.distance(0.5, 0.5) < 1e-6);
alg.normToPixel.compute(quadViewed.c.x, quadViewed.c.y, pixel);
alg.pixelToMarker(pixel.x, pixel.y, foundMarker);
assertTrue(foundMarker.distance(0.5, -0.5) < 1e-6);
alg.normToPixel.compute(quadViewed.d.x, quadViewed.d.y, pixel);
alg.pixelToMarker(pixel.x, pixel.y, foundMarker);
assertTrue(foundMarker.distance(-0.5, -0.5) < 1e-6);
}
use of georegression.struct.shapes.Quadrilateral_F64 in project BoofCV by lessthanoptimal.
the class ColorTrackerObjectRectangleChecks method render.
@Override
protected void render(double scale, double tranX, double tranY) {
// each region in the target region will have a different color. Allowing scale, translation, and rotation
// to be estimated using color information alone
Quadrilateral_F64 q = initRegion.copy();
// scale it down a bit so that there is a border
if (multiColor)
scale(q, 0.95);
Point2D_F64 ab = average(q.a, q.b);
Point2D_F64 bc = average(q.b, q.c);
Point2D_F64 cd = average(q.c, q.d);
Point2D_F64 da = average(q.d, q.a);
Point2D_F64 abcd = average(ab, cd);
Quadrilateral_F64 r0 = new Quadrilateral_F64(q.a, ab, abcd, da, true);
Quadrilateral_F64 r1 = new Quadrilateral_F64(ab, q.b, bc, abcd, true);
Quadrilateral_F64 r2 = new Quadrilateral_F64(abcd, bc, q.c, cd, true);
Quadrilateral_F64 r3 = new Quadrilateral_F64(da, abcd, cd, q.d, true);
Polygon2D_I32[] region = new Polygon2D_I32[4];
region[0] = setPolygon(r0);
region[1] = setPolygon(r1);
region[2] = setPolygon(r2);
region[3] = setPolygon(r3);
int[] band0 = new int[] { 100, 50, 176, 0 };
int[] band1 = new int[] { 150, 200, 240, 40 };
int[] band2 = new int[] { 20, 234, 176, 210 };
GImageMiscOps.fill(original, 0);
GImageMiscOps.fill(input, 0);
for (int i = 0; i < 4; i++) {
int colorIndex;
if (multiColor)
colorIndex = i;
else
colorIndex = 0;
TextureGrayTrackerObjectRectangleChecks.convexFill(region[i], original.getBand(0), band0[colorIndex]);
TextureGrayTrackerObjectRectangleChecks.convexFill(region[i], original.getBand(1), band1[colorIndex]);
TextureGrayTrackerObjectRectangleChecks.convexFill(region[i], original.getBand(2), band2[colorIndex]);
}
new FDistort(original, input).affine(scale, 0, 0, scale, tranX, tranY).apply();
}
use of georegression.struct.shapes.Quadrilateral_F64 in project BoofCV by lessthanoptimal.
the class ColorTrackerObjectRectangleTests method render.
@Override
protected void render(double scale, double tranX, double tranY) {
// each region in the target region will have a different color. Allowing scale, translation, and rotation
// to be estimated using color information alone
Quadrilateral_F64 q = initRegion.copy();
// scale it down a bit so that there is a border
if (multiColor)
scale(q, 0.95);
Point2D_F64 ab = average(q.a, q.b);
Point2D_F64 bc = average(q.b, q.c);
Point2D_F64 cd = average(q.c, q.d);
Point2D_F64 da = average(q.d, q.a);
Point2D_F64 abcd = average(ab, cd);
Quadrilateral_F64 r0 = new Quadrilateral_F64(q.a, ab, abcd, da, true);
Quadrilateral_F64 r1 = new Quadrilateral_F64(ab, q.b, bc, abcd, true);
Quadrilateral_F64 r2 = new Quadrilateral_F64(abcd, bc, q.c, cd, true);
Quadrilateral_F64 r3 = new Quadrilateral_F64(da, abcd, cd, q.d, true);
Polygon2D_I32[] region = new Polygon2D_I32[4];
region[0] = setPolygon(r0);
region[1] = setPolygon(r1);
region[2] = setPolygon(r2);
region[3] = setPolygon(r3);
int[] band0 = new int[] { 100, 50, 176, 0 };
int[] band1 = new int[] { 150, 200, 240, 40 };
int[] band2 = new int[] { 20, 234, 176, 210 };
GImageMiscOps.fill(original, 0);
GImageMiscOps.fill(input, 0);
for (int i = 0; i < 4; i++) {
int colorIndex;
if (multiColor)
colorIndex = i;
else
colorIndex = 0;
TextureGrayTrackerObjectRectangleTests.convexFill(region[i], original.getBand(0), band0[colorIndex]);
TextureGrayTrackerObjectRectangleTests.convexFill(region[i], original.getBand(1), band1[colorIndex]);
TextureGrayTrackerObjectRectangleTests.convexFill(region[i], original.getBand(2), band2[colorIndex]);
}
new FDistort(original, input).affine(scale, 0, 0, scale, tranX, tranY).apply();
}
use of georegression.struct.shapes.Quadrilateral_F64 in project BoofCV by lessthanoptimal.
the class GenericTrackerObjectRectangleTests method reinitialize.
/**
* See if it correctly reinitializes. Should produce identical results when given the same inputs after
* being reinitialized.
*/
@Test
public void reinitialize() {
Quadrilateral_F64 where1 = new Quadrilateral_F64();
TrackerObjectQuad<T> tracker = create(imageType);
render(1, 0, 0);
assertTrue(tracker.initialize(input, initRegion));
render(1, 3, -3);
assertTrue(tracker.process(input, where));
render(1, 6, -6);
assertTrue(tracker.process(input, where));
render(1, 0, 0);
assertTrue(tracker.initialize(input, initRegion));
render(1, 3, -3);
assertTrue(tracker.process(input, where1));
render(1, 6, -6);
assertTrue(tracker.process(input, where1));
// Might not be a perfect match due to robust algorithm not being reset to their initial state
checkSolution(where1.a.x, where1.a.y, where1.c.x, where1.c.y, 0.02);
}
Aggregations