Search in sources :

Example 56 with Point2D_F64

use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.

the class TestUniOmniPtoS_F64 method back_and_forth.

private void back_and_forth(double mirror) {
    CameraUniversalOmni model = createModel(mirror);
    UniOmniPtoS_F64 pixelToUnit = new UniOmniPtoS_F64();
    pixelToUnit.setModel(model);
    UniOmniStoP_F64 unitToPixel = new UniOmniStoP_F64();
    unitToPixel.setModel(model);
    List<Point2D_F64> listPixels = new ArrayList<>();
    listPixels.add(new Point2D_F64(320, 240));
    listPixels.add(new Point2D_F64(320, 200));
    listPixels.add(new Point2D_F64(320, 280));
    listPixels.add(new Point2D_F64(280, 240));
    listPixels.add(new Point2D_F64(360, 240));
    listPixels.add(new Point2D_F64(280, 240));
    listPixels.add(new Point2D_F64(240, 180));
    for (Point2D_F64 pixel : listPixels) {
        Point3D_F64 circle = new Point3D_F64(10, 10, 10);
        // directly forward on unit sphere
        pixelToUnit.compute(pixel.x, pixel.y, circle);
        // it should be on the unit circle
        assertEquals(1.0, circle.norm(), GrlConstants.TEST_F64);
        Point2D_F64 found = new Point2D_F64();
        unitToPixel.compute(circle.x, circle.y, circle.z, found);
        assertEquals(pixel.x, found.x, GrlConstants.TEST_SQ_F64);
        assertEquals(pixel.y, found.y, GrlConstants.TEST_SQ_F64);
    }
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) CameraUniversalOmni(boofcv.struct.calib.CameraUniversalOmni) Point2D_F64(georegression.struct.point.Point2D_F64) ArrayList(java.util.ArrayList)

Example 57 with Point2D_F64

use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.

the class TestUniOmniStoP_F64 method worldIsImageCenter.

/**
 * A point in the world center should appear in the image center
 */
@Test
public void worldIsImageCenter() {
    CameraUniversalOmni model = createModel(0.5);
    UniOmniStoP_F64 alg = new UniOmniStoP_F64();
    alg.setModel(model);
    Point2D_F64 found = new Point2D_F64(10, 10);
    // directly forward on unit sphere
    alg.compute(0, 0, 1, found);
    assertEquals(320, found.x, GrlConstants.TEST_F64);
    assertEquals(240, found.y, GrlConstants.TEST_F64);
}
Also used : CameraUniversalOmni(boofcv.struct.calib.CameraUniversalOmni) Point2D_F64(georegression.struct.point.Point2D_F64) Test(org.junit.Test)

Example 58 with Point2D_F64

use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.

the class TestPinholeNtoP_F64 method basicTest.

@Test
public void basicTest() {
    CameraPinholeRadial p = new CameraPinholeRadial().fsetK(1, 2, 3, 4, 5, 200, 300);
    DMatrixRMaj K = PerspectiveOps.calibrationMatrix(p, (DMatrixRMaj) null);
    Point2D_F64 pixel = new Point2D_F64(150, 200);
    Point2D_F64 expected = new Point2D_F64();
    Point2D_F64 found = new Point2D_F64();
    GeometryMath_F64.mult(K, pixel, expected);
    PinholeNtoP_F64 alg = new PinholeNtoP_F64();
    alg.set(p.fx, p.fy, p.skew, p.cx, p.cy);
    alg.compute(pixel.x, pixel.y, found);
    assertEquals(expected.x, found.x, 1e-8);
    assertEquals(expected.y, found.y, 1e-8);
}
Also used : CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) Point2D_F64(georegression.struct.point.Point2D_F64) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Test(org.junit.Test)

Example 59 with Point2D_F64

use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.

the class TestPinholePtoN_F64 method basic.

/**
 * Do the same calculation but using a different but equivalent equation
 */
@Test
public void basic() {
    PinholePtoN_F64 alg = new PinholePtoN_F64();
    alg.set(fx, fy, skew, x_c, y_c);
    Point2D_F64 in = new Point2D_F64(100, 120);
    Point2D_F64 out = new Point2D_F64();
    alg.compute(in.x, in.y, out);
    Point2D_F64 expected = new Point2D_F64();
    DMatrixRMaj K_inv = new DMatrixRMaj(3, 3, true, fx, skew, x_c, 0, fy, y_c, 0, 0, 1);
    CommonOps_DDRM.invert(K_inv);
    GeometryMath_F64.mult(K_inv, in, expected);
    assertEquals(expected.x, out.x, 1e-5);
    assertEquals(expected.y, out.y, 1e-5);
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Test(org.junit.Test)

Example 60 with Point2D_F64

use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.

the class TestAddRadialNtoN_F64 method againstManual.

/**
 * Manually compute the distorted coordinate for a point and see if it matches
 */
@Test
public void againstManual() {
    /**/
    double[] radial = new /**/
    double[] { 0.01, -0.03 };
    double t1 = 0.1, t2 = -0.05;
    Point2D_F64 orig = new Point2D_F64(0.1, -0.2);
    // manually compute the distortion
    double x = orig.x, y = orig.y;
    double r2 = x * x + y * y;
    double mag = (double) radial[0] * r2 + (double) radial[1] * r2 * r2;
    double distX = orig.x * (1 + mag) + 2 * t1 * x * y + t2 * (r2 + 2 * x * x);
    double distY = orig.y * (1 + mag) + t1 * (r2 + 2 * y * y) + 2 * t2 * x * y;
    AddRadialNtoN_F64 alg = new AddRadialNtoN_F64().setDistortion(radial, t1, t2);
    Point2D_F64 found = new Point2D_F64();
    alg.compute(orig.x, orig.y, found);
    assertEquals(distX, found.x, 1e-4);
    assertEquals(distY, found.y, 1e-4);
}
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