use of georegression.struct.point.Point2D_F32 in project BoofCV by lessthanoptimal.
the class TestNarrowToWidePtoP_F32 method checkFOVBounds.
/**
* Request points at the border and see if it has the expected vertical and horizontal FOV
*/
@Test
public void checkFOVBounds() {
NarrowToWidePtoP_F32 alg = createAlg();
Point2D_F32 foundA = new Point2D_F32();
Point2D_F32 foundB = new Point2D_F32();
Point3D_F32 vA = new Point3D_F32();
Point3D_F32 vB = new Point3D_F32();
// Compute the horizontal FOV
alg.compute(0, 250, foundA);
alg.compute(500, 250, foundB);
Point2Transform3_F32 wideToSphere = createModelWide().undistortPtoS_F32();
wideToSphere.compute(foundA.x, foundA.y, vA);
wideToSphere.compute(foundB.x, foundB.y, vB);
float found = UtilVector3D_F32.acute(new Vector3D_F32(vA), new Vector3D_F32(vB));
float expected = 2.0f * (float) Math.atan(250.0f / 400.0f);
assertEquals(expected, found, 0.01f);
// Compute the vertical FOV
alg.compute(250, 0, foundA);
alg.compute(250, 500, foundB);
wideToSphere.compute(foundA.x, foundA.y, vA);
wideToSphere.compute(foundB.x, foundB.y, vB);
found = UtilVector3D_F32.acute(new Vector3D_F32(vA), new Vector3D_F32(vB));
expected = 2.0f * (float) Math.atan(250.0f / 400.0f);
assertEquals(expected, found, 0.001f);
}
use of georegression.struct.point.Point2D_F32 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_F32 in project BoofCV by lessthanoptimal.
the class TestTransformThenPixel_F32 method compute.
@Test
public void compute() {
Transform2ThenPixel_F32 alg = new Transform2ThenPixel_F32(new Dummy());
alg.set(1, 2, 3, 4, 5);
float nx = 0.1f, ny = 0.2f;
float expectedX = 1 * nx + 3 * ny + 4;
float expectedY = 2 * ny + 5;
Point2D_F32 found = new Point2D_F32();
alg.compute(1, 2, found);
assertEquals(expectedX, found.x, 1e-8);
assertEquals(expectedY, found.y, 1e-8);
}
use of georegression.struct.point.Point2D_F32 in project BoofCV by lessthanoptimal.
the class TestPinholeNtoP_F32 method basicTest.
@Test
public void basicTest() {
CameraPinholeRadial p = new CameraPinholeRadial().fsetK(1, 2, 3, 4, 5, 200, 300);
FMatrixRMaj K = PerspectiveOps.calibrationMatrix(p, (FMatrixRMaj) null);
Point2D_F32 pixel = new Point2D_F32(150, 200);
Point2D_F32 expected = new Point2D_F32();
Point2D_F32 found = new Point2D_F32();
GeometryMath_F32.mult(K, pixel, expected);
PinholeNtoP_F32 alg = new PinholeNtoP_F32();
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);
}
use of georegression.struct.point.Point2D_F32 in project BoofCV by lessthanoptimal.
the class TestEquirectangularTools_F32 method equiToNorm_reverse.
private void equiToNorm_reverse(EquirectangularTools_F32 tools, float x, float y) {
Point3D_F32 n = new Point3D_F32();
Point2D_F32 r = new Point2D_F32();
tools.equiToNorm(x, y, n);
tools.normToEqui(n.x, n.y, n.z, r);
assertEquals(x, r.x, GrlConstants.TEST_F32);
assertEquals(y, r.y, GrlConstants.TEST_F32);
}
Aggregations