Search in sources :

Example 81 with Point2D_F32

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

the class TestLensDistortionOps method transformChangeModel_F32_FULLVIEW_modified.

/**
 * Checks to see if the returned modified model is correct
 */
@Test
public void transformChangeModel_F32_FULLVIEW_modified() {
    // distorted pixel in original image
    float pixelX = 12.5f, pixelY = height - 3;
    CameraPinholeRadial orig = new CameraPinholeRadial().fsetK(300, 320, 0, 150, 130, width, height).fsetRadial(0.1, 0.05);
    CameraPinhole desired = new CameraPinhole(orig);
    Point2Transform2_F32 distToNorm = LensDistortionOps.narrow(orig).undistort_F32(true, false);
    Point2D_F32 norm = new Point2D_F32();
    distToNorm.compute(pixelX, pixelY, norm);
    CameraPinholeRadial adjusted = new CameraPinholeRadial();
    Point2Transform2_F32 distToAdj = LensDistortionOps.transformChangeModel_F32(AdjustmentType.FULL_VIEW, orig, desired, false, adjusted);
    Point2D_F32 adjPixel = new Point2D_F32();
    Point2D_F32 normFound = new Point2D_F32();
    distToAdj.compute(pixelX, pixelY, adjPixel);
    PerspectiveOps.convertPixelToNorm(adjusted, adjPixel, normFound);
    // see if the normalized image coordinates are the same
    assertEquals(norm.x, normFound.x, 1e-3);
    assertEquals(norm.y, normFound.y, 1e-3);
}
Also used : CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) Point2D_F32(georegression.struct.point.Point2D_F32) Point2Transform2_F32(boofcv.struct.distort.Point2Transform2_F32) CameraPinhole(boofcv.struct.calib.CameraPinhole) Test(org.junit.Test)

Example 82 with Point2D_F32

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

the class TestLensDistortionOps method transformChangeModel_F32_NONE_modified.

@Test
public void transformChangeModel_F32_NONE_modified() {
    // distorted pixel in original image
    float pixelX = 12.5f, pixelY = height - 3;
    CameraPinholeRadial orig = new CameraPinholeRadial().fsetK(300, 320, 0, 150, 130, width, height).fsetRadial(0.1, 0.05);
    CameraPinhole desired = new CameraPinhole(orig);
    Point2Transform2_F32 distToNorm = LensDistortionOps.narrow(orig).undistort_F32(true, false);
    Point2D_F32 norm = new Point2D_F32();
    distToNorm.compute(pixelX, pixelY, norm);
    CameraPinhole adjusted = new CameraPinhole();
    Point2Transform2_F32 distToAdj = LensDistortionOps.transformChangeModel_F32(AdjustmentType.NONE, orig, desired, false, adjusted);
    Point2D_F32 adjPixel = new Point2D_F32();
    Point2D_F32 normFound = new Point2D_F32();
    distToAdj.compute(pixelX, pixelY, adjPixel);
    PerspectiveOps.convertPixelToNorm(adjusted, adjPixel, normFound);
    // see if the normalized image coordinates are the same
    assertEquals(norm.x, normFound.x, 1e-3);
    assertEquals(norm.y, normFound.y, 1e-3);
}
Also used : CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) Point2D_F32(georegression.struct.point.Point2D_F32) Point2Transform2_F32(boofcv.struct.distort.Point2Transform2_F32) CameraPinhole(boofcv.struct.calib.CameraPinhole) Test(org.junit.Test)

Example 83 with Point2D_F32

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

the class GeneralLensDistortionNarrowFOVChecks method forwardsBackwards_F32.

@Test
public void forwardsBackwards_F32() {
    LensDistortionNarrowFOV alg = create();
    for (int i = 0; i < 4; i++) {
        boolean inputPixel = i % 2 == 0;
        boolean outputPixel = i / 2 == 0;
        Point2Transform2_F32 distort = alg.distort_F32(inputPixel, outputPixel);
        Point2Transform2_F32 undistort = alg.undistort_F32(outputPixel, inputPixel);
        float inputX, inputY, scale;
        if (inputPixel) {
            inputX = 21.3f;
            inputY = 45.1f;
            scale = 10.0f;
        } else {
            inputX = 0.05f;
            inputY = -0.1f;
            scale = 0.1f;
        }
        Point2D_F32 middle = new Point2D_F32();
        Point2D_F32 found = new Point2D_F32();
        distort.compute(inputX, inputY, middle);
        undistort.compute(middle.x, middle.y, found);
        assertEquals(inputX, found.x, scale * tol_F32);
        assertEquals(inputY, found.y, scale * tol_F32);
    }
}
Also used : Point2D_F32(georegression.struct.point.Point2D_F32) Point2Transform2_F32(boofcv.struct.distort.Point2Transform2_F32) Test(org.junit.Test)

Example 84 with Point2D_F32

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

the class GeneralLensDistortionWideFOVChecks method blowup_extreme_angle_F32.

/**
 * Give it spherical coordinate pointing slightly behind.  See if it blows up when converting into pixels
 */
@Test
public void blowup_extreme_angle_F32() {
    LensDistortionWideFOV alg = create();
    Point3Transform2_F32 distort = alg.distortStoP_F32();
    Point2D_F32 found = new Point2D_F32();
    float x = 1.0f;
    float z = -0.001f;
    float r = (float) Math.sqrt(x * x + z * z);
    distort.compute(x / r, 0, z / x, found);
    assertTrue(!UtilEjml.isUncountable(found.x));
    assertTrue(!UtilEjml.isUncountable(found.y));
}
Also used : Point2D_F32(georegression.struct.point.Point2D_F32) Point3Transform2_F32(boofcv.struct.distort.Point3Transform2_F32) Test(org.junit.Test)

Example 85 with Point2D_F32

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

the class GeneralLensDistortionWideFOVChecks method pixel_unit_pixel_F32.

@Test
public void pixel_unit_pixel_F32() {
    LensDistortionWideFOV alg = create();
    Point2Transform3_F32 undistort = alg.undistortPtoS_F32();
    Point3Transform2_F32 distort = alg.distortStoP_F32();
    Point3D_F32 middle = new Point3D_F32();
    Point2D_F32 found = new Point2D_F32();
    undistort.compute(240, 260, middle);
    distort.compute(middle.x, middle.y, middle.z, found);
    assertEquals(240, found.x, pixel_tol_F32);
    assertEquals(260, found.y, pixel_tol_F32);
}
Also used : Point3D_F32(georegression.struct.point.Point3D_F32) Point2D_F32(georegression.struct.point.Point2D_F32) Point2Transform3_F32(boofcv.struct.distort.Point2Transform3_F32) Point3Transform2_F32(boofcv.struct.distort.Point3Transform2_F32) Test(org.junit.Test)

Aggregations

Point2D_F32 (georegression.struct.point.Point2D_F32)98 Test (org.junit.Test)36 Point3D_F32 (georegression.struct.point.Point3D_F32)10 Point2Transform2_F32 (boofcv.struct.distort.Point2Transform2_F32)9 LineSegment2D_F32 (georegression.struct.line.LineSegment2D_F32)8 ArrayList (java.util.ArrayList)8 Point2D_F64 (georegression.struct.point.Point2D_F64)7 FMatrixRMaj (org.ejml.data.FMatrixRMaj)7 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)5 LineParametric2D_F32 (georegression.struct.line.LineParametric2D_F32)5 Point2Transform3_F32 (boofcv.struct.distort.Point2Transform3_F32)4 Point3Transform2_F32 (boofcv.struct.distort.Point3Transform2_F32)4 GrayF32 (boofcv.struct.image.GrayF32)4 ClosestPoint2D_F32 (georegression.metric.ClosestPoint2D_F32)4 PointToPixelTransform_F32 (boofcv.alg.distort.PointToPixelTransform_F32)3 CameraPinhole (boofcv.struct.calib.CameraPinhole)3 GrayU8 (boofcv.struct.image.GrayU8)3 PixelTransformCached_F32 (boofcv.alg.distort.PixelTransformCached_F32)2 PinholePtoN_F32 (boofcv.alg.distort.pinhole.PinholePtoN_F32)2 CalibrationObservation (boofcv.alg.geo.calibration.CalibrationObservation)2