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);
}
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);
}
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);
}
}
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));
}
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);
}
Aggregations