Search in sources :

Example 41 with Point2D_F64

use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.

the class TestMultiViewOps method extractCameraMatrices.

@Test
public void extractCameraMatrices() {
    DMatrixRMaj P2 = new DMatrixRMaj(3, 4);
    DMatrixRMaj P3 = new DMatrixRMaj(3, 4);
    TrifocalTensor input = tensor.copy();
    MultiViewOps.extractCameraMatrices(input, P2, P3);
    // make sure the input was not modified
    for (int i = 0; i < 3; i++) assertTrue(MatrixFeatures_DDRM.isIdentical(tensor.getT(i), input.getT(i), 1e-8));
    // Using found camera matrices render the point's location
    Point3D_F64 X = new Point3D_F64(0.1, 0.05, 2);
    Point2D_F64 x1 = new Point2D_F64(X.x / X.z, X.y / X.z);
    Point2D_F64 x2 = PerspectiveOps.renderPixel(P2, X);
    Point2D_F64 x3 = PerspectiveOps.renderPixel(P3, X);
    // validate correctness by testing a constraint on the points
    DMatrixRMaj A = new DMatrixRMaj(3, 3);
    MultiViewOps.constraint(tensor, x1, x2, x3, A);
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            assertEquals(0, A.get(i, j), 1e-7);
        }
    }
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) TrifocalTensor(boofcv.struct.geo.TrifocalTensor) Point2D_F64(georegression.struct.point.Point2D_F64) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Test(org.junit.Test)

Example 42 with Point2D_F64

use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.

the class TestNormalizationPoint2D method apply_one.

@Test
public void apply_one() {
    NormalizationPoint2D n = new NormalizationPoint2D(1, 2, 3, 4);
    Point2D_F64 a = new Point2D_F64(1, 2);
    n.apply(a);
    n.remove(a);
    assertEquals(1, a.x, GrlConstants.TEST_F64);
    assertEquals(2, a.y, GrlConstants.TEST_F64);
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) Test(org.junit.Test)

Example 43 with Point2D_F64

use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.

the class TestPerspectiveOps method renderPixel_cameramatrix.

@Test
public void renderPixel_cameramatrix() {
    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;
    DMatrixRMaj P = PerspectiveOps.createCameraMatrix(worldToCamera.R, worldToCamera.T, K, null);
    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(P, 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 44 with Point2D_F64

use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.

the class TestPerspectiveOps method renderPixel_intrinsic.

@Test
public void renderPixel_intrinsic() {
    Point3D_F64 X = new Point3D_F64(0.1, -0.05, 3);
    CameraPinholeRadial intrinsic = new CameraPinholeRadial(100, 150, 0.1, 120, 209, 500, 600);
    double normX = X.x / X.z;
    double normY = X.y / X.z;
    Point2D_F64 expected = new Point2D_F64();
    PerspectiveOps.convertNormToPixel(intrinsic, normX, normY, expected);
    Point2D_F64 found = PerspectiveOps.renderPixel(intrinsic, X);
    assertEquals(expected.x, found.x, 1e-8);
    assertEquals(expected.y, found.y, 1e-8);
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) Point2D_F64(georegression.struct.point.Point2D_F64) Test(org.junit.Test)

Example 45 with Point2D_F64

use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.

the class TestPerspectiveOps method scaleIntrinsic.

@Test
public void scaleIntrinsic() {
    Point3D_F64 X = new Point3D_F64(0.1, 0.3, 2);
    CameraPinholeRadial param = new CameraPinholeRadial(200, 300, 2, 250, 260, 200, 300);
    DMatrixRMaj K = PerspectiveOps.calibrationMatrix(param, (DMatrixRMaj) null);
    // find the pixel location in the unscaled image
    Point2D_F64 a = PerspectiveOps.renderPixel(new Se3_F64(), K, X);
    PerspectiveOps.scaleIntrinsic(param, 0.5);
    K = PerspectiveOps.calibrationMatrix(param, (DMatrixRMaj) null);
    // find the pixel location in the scaled image
    Point2D_F64 b = PerspectiveOps.renderPixel(new Se3_F64(), K, X);
    assertEquals(a.x * 0.5, b.x, 1e-8);
    assertEquals(a.y * 0.5, b.y, 1e-8);
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) Point2D_F64(georegression.struct.point.Point2D_F64) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Se3_F64(georegression.struct.se.Se3_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