use of georegression.struct.point.Point3D_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.Point3D_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);
}
use of georegression.struct.point.Point3D_F32 in project BoofCV by lessthanoptimal.
the class TestEquirectangularTools_F32 method equiToNorm.
/**
* Test one very simple case with a known answer
*/
@Test
public void equiToNorm() {
EquirectangularTools_F32 tools = new EquirectangularTools_F32();
tools.configure(300, 250);
Point3D_F32 found = new Point3D_F32();
tools.equiToNorm(300.0f / 2.0f, 249.0f / 2.0f, found);
assertEquals(1.0f, found.x, GrlConstants.TEST_F32);
assertEquals(0.0f, found.y, GrlConstants.TEST_F32);
assertEquals(0.0f, found.z, GrlConstants.TEST_F32);
tools.equiToNorm(0, 249 / 2.0f, found);
assertTrue(found.distance(new Point3D_F32(-1, 0, 0)) <= GrlConstants.TEST_F32);
tools.equiToNorm(300, 249 / 2.0f, found);
assertTrue(found.distance(new Point3D_F32(-1, 0, 0)) <= GrlConstants.TEST_F32);
tools.equiToNorm(300 / 4, 249 / 2.0f, found);
assertTrue(found.distance(new Point3D_F32(0, -1, 0)) <= GrlConstants.TEST_F32);
tools.equiToNorm(3 * 300 / 4, 249 / 2.0f, found);
assertTrue(found.distance(new Point3D_F32(0, 1, 0)) <= GrlConstants.TEST_F32);
tools.equiToNorm(300 / 2, 0, found);
assertTrue(found.distance(new Point3D_F32(0, 0, 1)) <= GrlConstants.TEST_F32);
tools.equiToNorm(300 / 2, 249, found);
assertTrue(found.distance(new Point3D_F32(0, 0, -1)) <= GrlConstants.TEST_F32);
}
use of georegression.struct.point.Point3D_F32 in project BoofCV by lessthanoptimal.
the class TestUniOmniPtoS_F32 method back_and_forth.
private void back_and_forth(float mirror) {
CameraUniversalOmni model = createModel(mirror);
UniOmniPtoS_F32 pixelToUnit = new UniOmniPtoS_F32();
pixelToUnit.setModel(model);
UniOmniStoP_F32 unitToPixel = new UniOmniStoP_F32();
unitToPixel.setModel(model);
List<Point2D_F32> listPixels = new ArrayList<>();
listPixels.add(new Point2D_F32(320, 240));
listPixels.add(new Point2D_F32(320, 200));
listPixels.add(new Point2D_F32(320, 280));
listPixels.add(new Point2D_F32(280, 240));
listPixels.add(new Point2D_F32(360, 240));
listPixels.add(new Point2D_F32(280, 240));
listPixels.add(new Point2D_F32(240, 180));
for (Point2D_F32 pixel : listPixels) {
Point3D_F32 circle = new Point3D_F32(10, 10, 10);
// directly forward on unit sphere
pixelToUnit.compute(pixel.x, pixel.y, circle);
// it should be on the unit circle
assertEquals(1.0f, circle.norm(), GrlConstants.TEST_F32);
Point2D_F32 found = new Point2D_F32();
unitToPixel.compute(circle.x, circle.y, circle.z, found);
assertEquals(pixel.x, found.x, GrlConstants.TEST_SQ_F32);
assertEquals(pixel.y, found.y, GrlConstants.TEST_SQ_F32);
}
}
use of georegression.struct.point.Point3D_F32 in project BoofCV by lessthanoptimal.
the class TestUniOmniPtoS_F32 method centerIsCenter.
private void centerIsCenter(float mirror) {
CameraUniversalOmni model = createModel(mirror);
UniOmniPtoS_F32 alg = new UniOmniPtoS_F32();
alg.setModel(model);
Point3D_F32 found = new Point3D_F32(10, 10, 10);
// directly forward on unit sphere
alg.compute(320, 240, found);
assertEquals(0, found.x, GrlConstants.TEST_F32);
assertEquals(0, found.y, GrlConstants.TEST_F32);
assertEquals(1, found.z, GrlConstants.TEST_F32);
}
Aggregations