Search in sources :

Example 11 with Point4D_F64

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

the class GeoTestingOps method randomPointsH_F64.

public static List<Point4D_F64> randomPointsH_F64(double minX, double maxX, double minY, double maxY, double minZ, double maxZ, int num, Random rand) {
    List<Point4D_F64> ret = new ArrayList<>();
    for (int i = 0; i < num; i++) {
        double x = rand.nextDouble() * (maxX - minX) + minX;
        double y = rand.nextDouble() * (maxY - minY) + minY;
        double z = rand.nextDouble() * (maxZ - minZ) + minZ;
        double w = rand.nextDouble() * 0.01 + 1.0;
        ret.add(new Point4D_F64(x, y, z, w));
    }
    return ret;
}
Also used : ArrayList(java.util.ArrayList) Point4D_F64(georegression.struct.point.Point4D_F64)

Example 12 with Point4D_F64

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

the class GeneralCheckTriangulateRefineMetricH method incorrectInput.

@Test
void incorrectInput() {
    createScene();
    Point4D_F64 initial = convertH(worldPoint);
    initial.x += 0.01;
    initial.y += 0.1;
    initial.z += -0.05;
    initial.w *= 1.1;
    Point4D_F64 found = new Point4D_F64();
    triangulate(obsNorm, motionWorldToCamera, essential, initial, found);
    double error2 = worldPoint.distance(convertH(initial));
    double error = worldPoint.distance(convertH(found));
    assertTrue(error < error2 * 0.5);
}
Also used : Point4D_F64(georegression.struct.point.Point4D_F64) Test(org.junit.jupiter.api.Test)

Example 13 with Point4D_F64

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

the class GeneralCheckTriangulateRefineMetricH method perfectInput.

@Test
void perfectInput() {
    createScene();
    Point4D_F64 initial = convertH(worldPoint);
    Point4D_F64 found = new Point4D_F64();
    triangulate(obsNorm, motionWorldToCamera, essential, initial, found);
    assertEquals(0.0, worldPoint.distance(convertH(found)), UtilEjml.TEST_F64_SQ);
}
Also used : Point4D_F64(georegression.struct.point.Point4D_F64) Test(org.junit.jupiter.api.Test)

Example 14 with Point4D_F64

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

the class GenericBundleAdjustmentMetricChecks method checkReprojectionError.

public static void checkReprojectionError(SceneStructureMetric structure, SceneObservations observations, double tol) {
    BundlePinhole c = (BundlePinhole) structure.cameras.get(0).model;
    // making a bunch of assumptions here...
    CameraPinhole intrinsic = new CameraPinhole(c.fx, c.fy, c.skew, c.cx, c.cy, 600, 600);
    WorldToCameraToPixel wcp = new WorldToCameraToPixel();
    PointIndex2D_F64 o = new PointIndex2D_F64();
    Point2D_F64 predicted = new Point2D_F64();
    if (structure.homogenous) {
        Point4D_F64 p4 = new Point4D_F64();
        Point3D_F64 p3 = new Point3D_F64();
        for (int viewIndex = 0; viewIndex < observations.views.size; viewIndex++) {
            SceneObservations.View v = observations.views.data[viewIndex];
            Se3_F64 parent_to_view = structure.getParentToView(viewIndex);
            wcp.configure(intrinsic, parent_to_view);
            for (int j = 0; j < v.point.size; j++) {
                v.getPixel(j, o);
                structure.points.data[o.index].get(p4);
                p3.x = p4.x / p4.w;
                p3.y = p4.y / p4.w;
                p3.z = p4.z / p4.w;
                wcp.transform(p3, predicted);
                double residual = o.p.distance(predicted);
                if (Math.abs(residual) > tol)
                    fail("Error is too large. " + residual);
            }
        }
    } else {
        Point3D_F64 p3 = new Point3D_F64();
        for (int viewIndex = 0; viewIndex < observations.views.size; viewIndex++) {
            SceneObservations.View v = observations.views.data[viewIndex];
            Se3_F64 parent_to_view = structure.getParentToView(viewIndex);
            wcp.configure(intrinsic, parent_to_view);
            for (int j = 0; j < v.point.size; j++) {
                v.getPixel(j, o);
                structure.points.data[o.index].get(p3);
                wcp.transform(p3, predicted);
                double residual = o.p.distance(predicted);
                if (Math.abs(residual) > tol)
                    fail("Error is too large. " + residual);
            }
        }
    }
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) BundlePinhole(boofcv.alg.geo.bundle.cameras.BundlePinhole) PointIndex2D_F64(boofcv.struct.geo.PointIndex2D_F64) Point2D_F64(georegression.struct.point.Point2D_F64) Point4D_F64(georegression.struct.point.Point4D_F64) WorldToCameraToPixel(boofcv.alg.geo.WorldToCameraToPixel) CameraPinhole(boofcv.struct.calib.CameraPinhole) Se3_F64(georegression.struct.se.Se3_F64)

Example 15 with Point4D_F64

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

the class GeneralCheckTriangulateRefineProjective method incorrectInput.

@Test
void incorrectInput() {
    createScene();
    Point4D_F64 initial = convertH(worldPoint);
    initial.x += 0.01;
    initial.y += 0.1;
    initial.z += -0.05;
    initial.w *= 1.1;
    Point4D_F64 found = new Point4D_F64();
    triangulate(obsPixels, cameraMatrices, initial, found);
    double error2 = worldPoint.distance(convertH(initial));
    double error = worldPoint.distance(convertH(found));
    assertTrue(error < error2 * 0.5);
}
Also used : Point4D_F64(georegression.struct.point.Point4D_F64) Test(org.junit.jupiter.api.Test)

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