use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.
the class TestPerspectiveOps method convertNormToPixel_matrix.
@Test
public void convertNormToPixel_matrix() {
DMatrixRMaj K = new DMatrixRMaj(3, 3, true, 100, 0.1, 120, 0, 150, 209, 0, 0, 1);
Point2D_F64 norm = new Point2D_F64(-0.1, 0.25);
Point2D_F64 expected = new Point2D_F64();
GeometryMath_F64.mult(K, norm, expected);
Point2D_F64 found = PerspectiveOps.convertNormToPixel(K, norm, null);
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 TestPerspectiveOps method renderPixel_SE.
@Test
public void renderPixel_SE() {
Point3D_F64 X = new Point3D_F64(0.1, -0.05, 3);
Se3_F64 worldToCamera = new Se3_F64();
ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.1, -0.05, 0.03, worldToCamera.getR());
worldToCamera.getT().set(0.2, 0.01, -0.03);
DMatrixRMaj K = RandomMatrices_DDRM.triangularUpper(3, 0, -1, 1, rand);
Point3D_F64 X_cam = SePointOps_F64.transform(worldToCamera, X, null);
Point2D_F64 found;
// calibrated case
found = PerspectiveOps.renderPixel(worldToCamera, null, X);
assertEquals(X_cam.x / X_cam.z, found.x, 1e-8);
assertEquals(X_cam.y / X_cam.z, found.y, 1e-8);
// uncalibrated case
Point2D_F64 expected = new Point2D_F64();
expected.x = X_cam.x / X_cam.z;
expected.y = X_cam.y / X_cam.z;
GeometryMath_F64.mult(K, expected, expected);
found = PerspectiveOps.renderPixel(worldToCamera, K, X);
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 TestPositiveDepthConstraintCheck method testPositive.
/**
* Point a point in front of both cameras and see if it returns true
*/
@Test
public void testPositive() {
// create transform from A to B
DMatrixRMaj R = ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0, -0.05, 0, null);
Vector3D_F64 T = new Vector3D_F64(1, 0, 0);
Se3_F64 fromAtoB = new Se3_F64(R, T);
// point in front of both cameras
Point3D_F64 pt = new Point3D_F64(0, 0, 2);
// create observations of the point in calibrated coordinates
Point2D_F64 obsA = new Point2D_F64(0, 0);
Point3D_F64 pt_inB = SePointOps_F64.transform(fromAtoB, pt, null);
Point2D_F64 obsB = new Point2D_F64(pt_inB.x / pt_inB.z, pt_inB.y / pt_inB.z);
PositiveDepthConstraintCheck alg = new PositiveDepthConstraintCheck();
assertTrue(alg.checkConstraint(obsA, obsB, fromAtoB));
}
use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.
the class TestWorldToCameraToPixel method transform_two.
@Test
public void transform_two() {
WorldToCameraToPixel worldToPixel = new WorldToCameraToPixel();
worldToPixel.configure(intrinsic, worldToCamera);
Point2D_F64 found = new Point2D_F64();
assertTrue(worldToPixel.transform(infront, found));
assertTrue(found.distance(expectedInFront) < 1e-8);
assertFalse(worldToPixel.transform(behind, found));
}
use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.
the class TestWorldToCameraToPixel method transform_one.
@Test
public void transform_one() {
WorldToCameraToPixel worldToPixel = new WorldToCameraToPixel();
worldToPixel.configure(intrinsic, worldToCamera);
Point2D_F64 found = worldToPixel.transform(infront);
assertTrue(found != null);
assertTrue(found.distance(expectedInFront) < 1e-8);
assertTrue(null == worldToPixel.transform(behind));
}
Aggregations