use of georegression.struct.point.Point2D_F32 in project BoofCV by lessthanoptimal.
the class TestEquirectangularTools_F32 method lonlatToEquiFV.
@Test
public void lonlatToEquiFV() {
EquirectangularTools_F32 tools = new EquirectangularTools_F32();
tools.configure(width, height);
Point2D_F32 found = new Point2D_F32();
tools.latlonToEquiFV(-GrlConstants.F_PId2, 0, found);
assertEquals(width / 2, found.x, GrlConstants.TEST_F32);
assertEquals(height - 1, found.y, GrlConstants.TEST_F32);
tools.latlonToEquiFV(GrlConstants.F_PId2, 0, found);
assertEquals(width / 2, found.x, GrlConstants.TEST_F32);
assertEquals(0, found.y, GrlConstants.TEST_F32);
}
use of georegression.struct.point.Point2D_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.Point2D_F32 in project BoofCV by lessthanoptimal.
the class TestPinholePtoN_F32 method basic.
/**
* Do the same calculation but using a different but equivalent equation
*/
@Test
public void basic() {
PinholePtoN_F32 alg = new PinholePtoN_F32();
alg.set(fx, fy, skew, x_c, y_c);
Point2D_F32 in = new Point2D_F32(100, 120);
Point2D_F32 out = new Point2D_F32();
alg.compute(in.x, in.y, out);
Point2D_F32 expected = new Point2D_F32();
FMatrixRMaj K_inv = new FMatrixRMaj(3, 3, true, fx, skew, x_c, 0, fy, y_c, 0, 0, 1);
CommonOps_FDRM.invert(K_inv);
GeometryMath_F32.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_F32 in project BoofCV by lessthanoptimal.
the class TestAddRadialNtoN_F32 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 };
float t1 = 0.1f, t2 = -0.05f;
Point2D_F32 orig = new Point2D_F32(0.1f, -0.2f);
// manually compute the distortion
float x = orig.x, y = orig.y;
float r2 = x * x + y * y;
float mag = (float) radial[0] * r2 + (float) radial[1] * r2 * r2;
float distX = orig.x * (1 + mag) + 2 * t1 * x * y + t2 * (r2 + 2 * x * x);
float distY = orig.y * (1 + mag) + t1 * (r2 + 2 * y * y) + 2 * t2 * x * y;
AddRadialNtoN_F32 alg = new AddRadialNtoN_F32().setDistortion(radial, t1, t2);
Point2D_F32 found = new Point2D_F32();
alg.compute(orig.x, orig.y, found);
assertEquals(distX, found.x, 1e-4);
assertEquals(distY, found.y, 1e-4);
}
use of georegression.struct.point.Point2D_F32 in project BoofCV by lessthanoptimal.
the class TestAddRadialPtoN_F32 method againstManual.
public void againstManual(float t1, float t2) {
float fx = 600;
float fy = 500;
float skew = 2;
float xc = 300;
float yc = 350;
/**/
double[] radial = new /**/
double[] { 0.01, -0.03 };
// undistorted pixel coordinates
Point2D_F32 orig = new Point2D_F32(19.5f, 400.1f);
Point2D_F32 normPt = new Point2D_F32();
FMatrixRMaj K = new FMatrixRMaj(3, 3, true, fx, skew, xc, 0, fy, yc, 0, 0, 1);
FMatrixRMaj K_inv = new FMatrixRMaj(3, 3);
CommonOps_FDRM.invert(K, K_inv);
// compute normalized image coordinate
GeometryMath_F32.mult(K_inv, orig, normPt);
// undistorted normalized image coordinates
float nx = normPt.x;
float ny = normPt.y;
float r2 = nx * nx + ny * ny;
float ri2 = 1;
float sum = 0;
for (int i = 0; i < radial.length; i++) {
ri2 *= r2;
sum += radial[i] * ri2;
}
// distorted normalized image coordinates
float dnx = nx + nx * sum + 2 * t1 * nx * ny + t2 * (r2 + 2 * nx * nx);
float dny = ny + ny * sum + t1 * (r2 + 2 * ny * ny) + 2 * t2 * nx * ny;
AddRadialPtoN_F32 alg = new AddRadialPtoN_F32().setK(fx, fy, skew, xc, yc).setDistortion(radial, t1, t2);
Point2D_F32 found = new Point2D_F32();
alg.compute(orig.x, orig.y, found);
assertEquals(dnx, found.x, 1e-4);
assertEquals(dny, found.y, 1e-4);
}
Aggregations