Search in sources :

Example 96 with Point2D_F64

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

the class CommonTriangulationChecks method createScene.

public void createScene() {
    worldPoint = new Point3D_F64(0.1, -0.2, 4);
    motionWorldToCamera = new ArrayList<>();
    obsPts = new ArrayList<>();
    essential = new ArrayList<>();
    Point3D_F64 cameraPoint = new Point3D_F64();
    for (int i = 0; i < N; i++) {
        // random motion from world to frame 'i'
        Se3_F64 tranWtoI = new Se3_F64();
        if (i > 0) {
            tranWtoI.getR().set(ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, rand.nextGaussian() * 0.01, rand.nextGaussian() * 0.05, rand.nextGaussian() * 0.1, null));
            tranWtoI.getT().set(0.2 + rand.nextGaussian() * 0.1, rand.nextGaussian() * 0.1, rand.nextGaussian() * 0.01);
        }
        DMatrixRMaj E = MultiViewOps.createEssential(tranWtoI.getR(), tranWtoI.getT());
        SePointOps_F64.transform(tranWtoI, worldPoint, cameraPoint);
        Point2D_F64 o = new Point2D_F64(cameraPoint.x / cameraPoint.z, cameraPoint.y / cameraPoint.z);
        obsPts.add(o);
        motionWorldToCamera.add(tranWtoI);
        essential.add(E);
    }
}
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)

Example 97 with Point2D_F64

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

the class TestPixelDepthLinear method depth2View.

@Test
public void depth2View() {
    // define the camera's motion
    Se3_F64 motion1 = new Se3_F64();
    motion1.getR().set(ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.05, -0.03, 0.02, null));
    motion1.getT().set(0.1, -0.1, 0.01);
    // compute the point's location in each camera's view
    Point3D_F64 A = new Point3D_F64(2, 3, 2);
    Point3D_F64 B = SePointOps_F64.transform(motion1, A, null);
    // projected points
    Point2D_F64 x1 = new Point2D_F64(A.x / A.z, A.y / A.z);
    Point2D_F64 x2 = new Point2D_F64(B.x / B.z, B.y / B.z);
    PixelDepthLinear alg = new PixelDepthLinear();
    double depth = alg.depth2View(x1, x2, motion1);
    // see if the origin point was recomputed
    assertEquals(x1.x * depth, A.x, 1e-8);
    assertEquals(x1.y * depth, A.y, 1e-8);
    assertEquals(depth, A.z, 1e-8);
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) Point2D_F64(georegression.struct.point.Point2D_F64) Se3_F64(georegression.struct.se.Se3_F64) Test(org.junit.Test)

Example 98 with Point2D_F64

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

the class TestPixelDepthLinear method depthNView.

@Test
public void depthNView() {
    // define the camera's motion
    Se3_F64 motion1 = new Se3_F64();
    motion1.getR().set(ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.05, -0.03, 0.02, null));
    motion1.getT().set(0.1, -0.1, 0.01);
    Se3_F64 motion2 = new Se3_F64();
    motion2.getR().set(ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, -0.15, -0.3, 0.08, null));
    motion2.getT().set(-0.2, -0.15, 0.2);
    // compute the point's location in each camera's view
    Point3D_F64 A = new Point3D_F64(2, 3, 2);
    Point3D_F64 B = SePointOps_F64.transform(motion1, A, null);
    Point3D_F64 C = SePointOps_F64.transform(motion2, A, null);
    // projected points
    Point2D_F64 x1 = new Point2D_F64(A.x / A.z, A.y / A.z);
    Point2D_F64 x2 = new Point2D_F64(B.x / B.z, B.y / B.z);
    Point2D_F64 x3 = new Point2D_F64(C.x / C.z, C.y / C.z);
    // setup data structures
    List<Se3_F64> listMotion = new ArrayList<>();
    List<Point2D_F64> listPoint = new ArrayList<>();
    listMotion.add(motion1);
    listMotion.add(motion2);
    listPoint.add(x1);
    listPoint.add(x2);
    listPoint.add(x3);
    PixelDepthLinear alg = new PixelDepthLinear();
    double depth = alg.depthNView(listPoint, listMotion);
    // see if the origin point was recomputed
    assertEquals(x1.x * depth, A.x, 1e-8);
    assertEquals(x1.y * depth, A.y, 1e-8);
    assertEquals(depth, A.z, 1e-8);
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) Point2D_F64(georegression.struct.point.Point2D_F64) ArrayList(java.util.ArrayList) Se3_F64(georegression.struct.se.Se3_F64) Test(org.junit.Test)

Example 99 with Point2D_F64

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

the class CommonHomographyInducedPlane method checkHomography.

public void checkHomography(DMatrixRMaj H) {
    Point2D_F64 found = new Point2D_F64();
    GeometryMath_F64.mult(H, p4.p1, found);
    assertTrue(found.isIdentical(p4.p2, 1e-8));
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64)

Example 100 with Point2D_F64

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

the class TestHomographyDirectLinearTransform method checkHomography.

/**
 * Create a set of points perfectly on a plane and provide perfect observations of them
 *
 * @param N Number of observed points.
 * @param isPixels Pixel or calibrated coordinates
 * @param alg Algorithm being evaluated
 */
private void checkHomography(int N, boolean isPixels, HomographyDirectLinearTransform alg) {
    createScene(N, isPixels);
    // compute essential
    assertTrue(alg.process(pairs, solution));
    // validate by testing essential properties
    // sanity check, F is not zero
    assertTrue(NormOps_DDRM.normF(solution) > 0.001);
    // see if it follows the epipolar constraint
    for (AssociatedPair p : pairs) {
        Point2D_F64 a = GeometryMath_F64.mult(solution, p.p1, new Point2D_F64());
        double diff = a.distance(p.p2);
        assertEquals(0, diff, 1e-8);
    }
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) Point2D_F64(georegression.struct.point.Point2D_F64)

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