Search in sources :

Example 31 with Point2D_F64

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);
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) Test(org.junit.Test)

Example 32 with Point2D_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);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) Point2D_F64(georegression.struct.point.Point2D_F64) Point2D_F32(georegression.struct.point.Point2D_F32) Test(org.junit.Test)

Example 33 with Point2D_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);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) Point2D_F64(georegression.struct.point.Point2D_F64) Test(org.junit.Test)

Example 34 with Point2D_F64

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();
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) FMatrixRMaj(org.ejml.data.FMatrixRMaj) FDistort(boofcv.abst.distort.FDistort) Estimate1ofEpipolar(boofcv.abst.geo.Estimate1ofEpipolar) Point2D_F64(georegression.struct.point.Point2D_F64) ArrayList(java.util.ArrayList) DMatrixRMaj(org.ejml.data.DMatrixRMaj)

Example 35 with Point2D_F64

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);
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) Test(org.junit.Test)

Aggregations

Point2D_F64 (georegression.struct.point.Point2D_F64)360 Test (org.junit.Test)129 Point3D_F64 (georegression.struct.point.Point3D_F64)85 Se3_F64 (georegression.struct.se.Se3_F64)68 ArrayList (java.util.ArrayList)57 DMatrixRMaj (org.ejml.data.DMatrixRMaj)48 AssociatedPair (boofcv.struct.geo.AssociatedPair)28 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)16 Point2Transform2_F64 (boofcv.struct.distort.Point2Transform2_F64)15 GrayF32 (boofcv.struct.image.GrayF32)13 Vector3D_F64 (georegression.struct.point.Vector3D_F64)13 Polygon2D_F64 (georegression.struct.shapes.Polygon2D_F64)13 Point2D3D (boofcv.struct.geo.Point2D3D)11 GrayU8 (boofcv.struct.image.GrayU8)11 Point2D_I32 (georegression.struct.point.Point2D_I32)11 AssociatedIndex (boofcv.struct.feature.AssociatedIndex)10 EllipseRotated_F64 (georegression.struct.curve.EllipseRotated_F64)9 DescribeRegionPoint (boofcv.abst.feature.describe.DescribeRegionPoint)8 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)8 BufferedImage (java.awt.image.BufferedImage)8