Search in sources :

Example 46 with Point2D_F64

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);
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Test(org.junit.Test)

Example 47 with Point2D_F64

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);
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) Point2D_F64(georegression.struct.point.Point2D_F64) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Se3_F64(georegression.struct.se.Se3_F64) Test(org.junit.Test)

Example 48 with Point2D_F64

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));
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) Vector3D_F64(georegression.struct.point.Vector3D_F64) Point2D_F64(georegression.struct.point.Point2D_F64) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Se3_F64(georegression.struct.se.Se3_F64) Test(org.junit.Test)

Example 49 with Point2D_F64

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));
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) Test(org.junit.Test)

Example 50 with Point2D_F64

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));
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) Test(org.junit.Test)

Aggregations

Point2D_F64 (georegression.struct.point.Point2D_F64)360 Test (org.junit.Test)129 Point3D_F64 (georegression.struct.point.Point3D_F64)85 Se3_F64 (georegression.struct.se.Se3_F64)68 ArrayList (java.util.ArrayList)57 DMatrixRMaj (org.ejml.data.DMatrixRMaj)48 AssociatedPair (boofcv.struct.geo.AssociatedPair)28 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)16 Point2Transform2_F64 (boofcv.struct.distort.Point2Transform2_F64)15 GrayF32 (boofcv.struct.image.GrayF32)13 Vector3D_F64 (georegression.struct.point.Vector3D_F64)13 Polygon2D_F64 (georegression.struct.shapes.Polygon2D_F64)13 Point2D3D (boofcv.struct.geo.Point2D3D)11 GrayU8 (boofcv.struct.image.GrayU8)11 Point2D_I32 (georegression.struct.point.Point2D_I32)11 AssociatedIndex (boofcv.struct.feature.AssociatedIndex)10 EllipseRotated_F64 (georegression.struct.curve.EllipseRotated_F64)9 DescribeRegionPoint (boofcv.abst.feature.describe.DescribeRegionPoint)8 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)8 BufferedImage (java.awt.image.BufferedImage)8