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