use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.
the class TestNarrowToWidePtoP_F64 method centerIsCenter.
/**
* With no translation request a point in the center. Should appear to be in the center in both views.
*/
@Test
public void centerIsCenter() {
NarrowToWidePtoP_F64 alg = createAlg();
Point2D_F64 found = new Point2D_F64();
alg.compute(250, 250, found);
assertEquals(480, found.x, GrlConstants.TEST_SQ_F64);
assertEquals(480, found.y, GrlConstants.TEST_SQ_F64);
}
use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.
the class TestRemovePerspectiveDistortion method identity.
/**
* The transform should not scale and produce a simple transform from input to output
*/
@Test
public void identity() {
RemovePerspectiveDistortion<GrayF32> alg = new RemovePerspectiveDistortion<>(30, 40, ImageType.single(GrayF32.class));
alg.createTransform(new Point2D_F64(20, 30), new Point2D_F64(50, 30), new Point2D_F64(50, 70), new Point2D_F64(20, 70));
Point2D_F32 p = new Point2D_F32();
PointTransformHomography_F32 transform = alg.getTransform();
transform.compute(0, 0, p);
assertTrue(p.distance(20, 30) < UtilEjml.TEST_F64);
transform.compute(30, 40, p);
assertTrue(p.distance(50, 70) < UtilEjml.TEST_F64);
}
use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.
the class TestRemovePerspectiveDistortion method undoDistortion.
@Test
public void undoDistortion() {
GrayF32 expected = new GrayF32(30, 40);
GrayF32 input = new GrayF32(200, 150);
Point2D_F64 topLeft = new Point2D_F64(30, 20);
Point2D_F64 topRight = new Point2D_F64(80, 30);
Point2D_F64 bottomRight = new Point2D_F64(70, 90);
Point2D_F64 bottomLeft = new Point2D_F64(25, 80);
GImageMiscOps.fill(expected, 255);
GImageMiscOps.fillRectangle(expected, 100, 10, 10, 15, 25);
// apply homography distortion to expected
applyForwardTransform(expected, input, topLeft, topRight, bottomRight, bottomLeft);
// now reverse it with the class
RemovePerspectiveDistortion<GrayF32> alg = new RemovePerspectiveDistortion<>(30, 40, ImageType.single(GrayF32.class));
assertTrue(alg.apply(input, topLeft, topRight, bottomRight, bottomLeft));
GrayF32 found = alg.getOutput();
GrayF32 difference = found.createSameShape();
PixelMath.diffAbs(expected, found, difference);
double error = ImageStatistics.sum(difference) / (difference.width * difference.height);
assertTrue(error < 10);
}
use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.
the class TestRemovePerspectiveDistortion method applyForwardTransform.
private void applyForwardTransform(GrayF32 expected, GrayF32 input, Point2D_F64 topLeft, Point2D_F64 topRight, Point2D_F64 bottomRight, Point2D_F64 bottomLeft) {
Estimate1ofEpipolar computeHomography = FactoryMultiView.computeHomographyDLT(true);
ArrayList<AssociatedPair> associatedPairs = new ArrayList<>();
associatedPairs.add(new AssociatedPair(topLeft, new Point2D_F64(0, 0)));
associatedPairs.add(new AssociatedPair(topRight, new Point2D_F64(expected.width - 1, 0)));
associatedPairs.add(new AssociatedPair(bottomRight, new Point2D_F64(expected.width - 1, expected.height - 1)));
associatedPairs.add(new AssociatedPair(bottomLeft, new Point2D_F64(0, expected.height - 1)));
DMatrixRMaj H = new DMatrixRMaj(3, 3);
computeHomography.process(associatedPairs, H);
FMatrixRMaj H32 = new FMatrixRMaj(3, 3);
ConvertMatrixData.convert(H, H32);
new FDistort(expected, input).transform(new PointTransformHomography_F32(H32)).apply();
}
use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.
the class TestTransformThenPixel_F64 method compute.
@Test
public void compute() {
Transform2ThenPixel_F64 alg = new Transform2ThenPixel_F64(new Dummy());
alg.set(1, 2, 3, 4, 5);
double nx = 0.1, ny = 0.2;
double expectedX = 1 * nx + 3 * ny + 4;
double expectedY = 2 * ny + 5;
Point2D_F64 found = new Point2D_F64();
alg.compute(1, 2, found);
assertEquals(expectedX, found.x, 1e-8);
assertEquals(expectedY, found.y, 1e-8);
}
Aggregations