Search in sources :

Example 16 with Point4D_F64

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

the class GeneralCheckTriangulateRefineProjective method perfectInput.

@Test
void perfectInput() {
    createScene();
    Point4D_F64 initial = convertH(worldPoint);
    Point4D_F64 found = new Point4D_F64();
    triangulate(obsPixels, cameraMatrices, initial, found);
    assertEquals(worldPoint.x, convertH(found).x, 1e-8);
}
Also used : Point4D_F64(georegression.struct.point.Point4D_F64) Test(org.junit.jupiter.api.Test)

Example 17 with Point4D_F64

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

the class GeneralCheckTriangulate2ViewsProjective method triangulate.

/**
 * See if it can triangulate perfect observations
 */
@Test
void triangulate() {
    Point3D_F64 world = new Point3D_F64(0.5, -0.1, 4);
    Se3_F64 worldToA = new Se3_F64();
    Se3_F64 worldToB = new Se3_F64();
    worldToB.getT().setTo(2, 0.1, -0.5);
    ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0, 0.05, 0, worldToB.getR());
    Point3D_F64 pointA = SePointOps_F64.transform(worldToA, world, null);
    Point2D_F64 viewA = new Point2D_F64();
    viewA.x = pointA.x / pointA.z;
    viewA.y = pointA.y / pointA.z;
    Point3D_F64 pointB = SePointOps_F64.transform(worldToB, world, null);
    Point2D_F64 viewB = new Point2D_F64();
    viewB.x = pointB.x / pointB.z;
    viewB.y = pointB.y / pointB.z;
    Triangulate2ViewsProjective alg = createAlg();
    Point4D_F64 found = new Point4D_F64();
    DMatrixRMaj P1 = new DMatrixRMaj(3, 4);
    CommonOps_DDRM.setIdentity(P1);
    DMatrixRMaj P2 = PerspectiveOps.convertToMatrix(worldToB, null);
    alg.triangulate(viewA, viewB, P1, P2, found);
    assertEquals(found.x / found.w, world.x, 1e-8);
    assertEquals(found.y / found.w, world.y, 1e-8);
    assertEquals(found.z / found.w, world.z, 1e-8);
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) Point2D_F64(georegression.struct.point.Point2D_F64) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Point4D_F64(georegression.struct.point.Point4D_F64) Se3_F64(georegression.struct.se.Se3_F64) Test(org.junit.jupiter.api.Test)

Example 18 with Point4D_F64

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

the class TestPruneStructureFromSceneProjective method createRestOfScene.

private void createRestOfScene() {
    observations = new SceneObservations();
    observations.initialize(structure.views.size);
    Point4D_F64 X = new Point4D_F64();
    Point3D_F64 xx = new Point3D_F64();
    Point2D_F64 x = new Point2D_F64();
    for (int viewIdx = 0; viewIdx < structure.views.size; viewIdx++) {
        SceneStructureProjective.View vs = structure.views.data[viewIdx];
        DMatrixRMaj P = vs.worldToView;
        int width = vs.width;
        int height = vs.height;
        SceneObservations.View vo = observations.views.data[viewIdx];
        for (int pointIdx = 0; pointIdx < structure.points.size; pointIdx++) {
            SceneStructureCommon.Point ps = structure.points.data[pointIdx];
            ps.get(X);
            GeometryMath_F64.mult(P, X, xx);
            // behind the camera. I think...
            if (Math.signum(X.w) * xx.z < 0)
                continue;
            x.x = xx.x / xx.z;
            x.y = xx.y / xx.z;
            if (x.x >= 0 && x.x <= width && x.y >= 0 && x.y <= height) {
                ps.views.add(viewIdx);
                vo.add(pointIdx, (float) x.x, (float) x.y);
            }
        }
    }
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) SceneStructureProjective(boofcv.abst.geo.bundle.SceneStructureProjective) SceneObservations(boofcv.abst.geo.bundle.SceneObservations) Point2D_F64(georegression.struct.point.Point2D_F64) DMatrixRMaj(org.ejml.data.DMatrixRMaj) UtilPoint4D_F64(georegression.geometry.UtilPoint4D_F64) Point4D_F64(georegression.struct.point.Point4D_F64) SceneStructureCommon(boofcv.abst.geo.bundle.SceneStructureCommon)

Example 19 with Point4D_F64

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

the class TestCompatibleProjectiveHomography method checkWorldPointsH.

private void checkWorldPointsH(DMatrixRMaj H, double tol) {
    Point4D_F64 found = new Point4D_F64();
    for (int i = 0; i < triples.size(); i++) {
        Point4D_F64 X = worldPts.get(i);
        Point4D_F64 Xb = sceneB.get(i);
        GeometryMath_F64.mult(H, Xb, found);
        X.scale(1.0 / X.norm());
        found.scale(1.0 / found.norm());
        double error = X.distance(found);
        found.scale(-1);
        error = Math.min(error, X.distance(found));
        assertEquals(0.0, error, tol);
    }
}
Also used : Point4D_F64(georegression.struct.point.Point4D_F64)

Example 20 with Point4D_F64

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

the class CommonHomographyChecks method createRandomPlaneH.

/**
 * Create a random set of points which line on the x-y plane at distance 'd'
 */
public static List<Point4D_F64> createRandomPlaneH(Random rand, double d, int N) {
    List<Point4D_F64> ret = new ArrayList<>();
    for (int i = 0; i < N; i++) {
        double x = (rand.nextDouble() - 0.5) * 2;
        double y = (rand.nextDouble() - 0.5) * 2;
        // make it more interesting by not having the same W for all the point
        double scale = rand.nextDouble() + 0.1;
        if (rand.nextBoolean())
            scale *= -1;
        ret.add(new Point4D_F64(scale * x, scale * y, scale * d, scale));
    }
    return ret;
}
Also used : ArrayList(java.util.ArrayList) Point4D_F64(georegression.struct.point.Point4D_F64)

Aggregations

Point4D_F64 (georegression.struct.point.Point4D_F64)57 Point2D_F64 (georegression.struct.point.Point2D_F64)25 Test (org.junit.jupiter.api.Test)25 DMatrixRMaj (org.ejml.data.DMatrixRMaj)19 Point3D_F64 (georegression.struct.point.Point3D_F64)12 Se3_F64 (georegression.struct.se.Se3_F64)11 ArrayList (java.util.ArrayList)9 SceneObservations (boofcv.abst.geo.bundle.SceneObservations)5 SceneStructureProjective (boofcv.abst.geo.bundle.SceneStructureProjective)5 SceneStructureCommon (boofcv.abst.geo.bundle.SceneStructureCommon)4 AssociatedTriple (boofcv.struct.geo.AssociatedTriple)4 DogArray_I32 (org.ddogleg.struct.DogArray_I32)4 SceneStructureMetric (boofcv.abst.geo.bundle.SceneStructureMetric)3 CameraPinhole (boofcv.struct.calib.CameraPinhole)3 AssociatedPair (boofcv.struct.geo.AssociatedPair)3 UtilPoint4D_F64 (georegression.geometry.UtilPoint4D_F64)3 DogArray (org.ddogleg.struct.DogArray)3 TriangulateNViewsMetricH (boofcv.abst.geo.TriangulateNViewsMetricH)2 RemoveBrownPtoN_F64 (boofcv.alg.distort.brown.RemoveBrownPtoN_F64)2 BundlePinhole (boofcv.alg.geo.bundle.cameras.BundlePinhole)2