Search in sources :

Example 46 with SceneStructureMetric

use of boofcv.abst.geo.bundle.SceneStructureMetric in project BoofCV by lessthanoptimal.

the class TestMultiViewStereoFromKnownSceneStructure method createScene.

private void createScene(int numViews) {
    scene = new SceneStructureMetric(true);
    scene.initialize(numViews, numViews, 0);
    pairs = new StereoPairGraph();
    for (int i = 0; i < numViews; i++) {
        // give it a reasonable camera
        double cx = width / 2.0;
        double cy = height / 2.0;
        scene.setCamera(i, true, new CameraPinhole(cx, cx, 0, cx, cy, width, height));
        scene.setView(i, i, true, SpecialEuclideanOps_F64.eulerXyz((i - 1) * 0.3, 0, 0, 0, 0, 0, null));
        pairs.addVertex("id=" + i, i);
    }
    // connect all views to each other with high quality geometric info
    for (int i = 0; i < numViews; i++) {
        for (int j = i + 1; j < numViews; j++) {
            pairs.connect("id=" + i, "id=" + j, 1.0);
        }
    }
}
Also used : SceneStructureMetric(boofcv.abst.geo.bundle.SceneStructureMetric) CameraPinhole(boofcv.struct.calib.CameraPinhole)

Example 47 with SceneStructureMetric

use of boofcv.abst.geo.bundle.SceneStructureMetric in project BoofCV by lessthanoptimal.

the class TestScenePointsSetIterator method basic.

@Test
void basic() {
    var scene = new SceneStructureMetric(true);
    scene.initialize(1, 1, 5);
    for (int i = 0; i < 5; i++) {
        scene.setPoint(i, 1, i + 2, 3, 4);
    }
    var indexes = DogArray_I32.array(1, 3);
    var alg = new ScenePointsSetIterator<>(scene, indexes, new PointIndex4D_F64());
    for (int i = 0; i < indexes.size; i++) {
        assertTrue(alg.hasNext());
        PointIndex4D_F64 found = alg.next();
        assertEquals(i * 2 + 1, found.index);
        assertEquals(0.0, found.p.distance(1, (i * 2 + 3), 3, 4), UtilEjml.TEST_F64);
    }
    assertFalse(alg.hasNext());
}
Also used : SceneStructureMetric(boofcv.abst.geo.bundle.SceneStructureMetric) PointIndex4D_F64(boofcv.struct.geo.PointIndex4D_F64) Test(org.junit.jupiter.api.Test)

Example 48 with SceneStructureMetric

use of boofcv.abst.geo.bundle.SceneStructureMetric in project BoofCV by lessthanoptimal.

the class TestThreeViewEstimateMetricScene method perfectData.

@Test
void perfectData() {
    ThreeViewEstimateMetricScene alg = new ThreeViewEstimateMetricScene();
    assertTrue(alg.process(views, 900, 900));
    // See if the reconstructed seen matches the original to within a high level of precision
    SceneStructureMetric structure = alg.getStructure();
    for (int i = 0; i < 3; i++) {
        BundlePinholeSimplified c = structure.getCameras().get(i).getModel();
        assertEquals(intrinsic.fx, c.f, 1e-4);
        assertEquals(0, c.k1, 1e-5);
        assertEquals(0, c.k2, 1e-5);
    }
    Se3_F64 found1 = structure.getParentToView(1);
    Se3_F64 found2 = structure.getParentToView(2);
    view0_to_view1.T.normalize();
    found1.T.normalize();
    assertEquals(0, found1.T.distance(view0_to_view1.T), 1e-4);
    view0_to_view2.T.normalize();
    found2.T.normalize();
    assertEquals(0, found2.T.distance(view0_to_view2.T), 1e-4);
    double[] found_xyz = ConvertRotation3D_F64.matrixToEuler(found1.R, EulerType.XYZ, null);
    double[] expec_xyz = ConvertRotation3D_F64.matrixToEuler(view0_to_view1.R, EulerType.XYZ, null);
    for (int i = 0; i < 3; i++) {
        assertEquals(expec_xyz[i], found_xyz[i], 1e-4);
    }
    found_xyz = ConvertRotation3D_F64.matrixToEuler(found2.R, EulerType.XYZ, null);
    expec_xyz = ConvertRotation3D_F64.matrixToEuler(view0_to_view2.R, EulerType.XYZ, null);
    for (int i = 0; i < 3; i++) {
        assertEquals(expec_xyz[i], found_xyz[i], 1e-4);
    }
}
Also used : SceneStructureMetric(boofcv.abst.geo.bundle.SceneStructureMetric) BundlePinholeSimplified(boofcv.alg.geo.bundle.cameras.BundlePinholeSimplified) Se3_F64(georegression.struct.se.Se3_F64) Test(org.junit.jupiter.api.Test)

Example 49 with SceneStructureMetric

use of boofcv.abst.geo.bundle.SceneStructureMetric in project BoofCV by lessthanoptimal.

the class TestGenerateStereoPairGraphFromScene method matchPointsToViews.

@Test
void matchPointsToViews() {
    var scene = new SceneStructureMetric(false);
    // Create a scene with 3 views and a simple formula relating visible points to views
    scene.initialize(3, 3, 10);
    for (int i = 0; i < 3; i++) {
        scene.setView(i, i, true, new Se3_F64());
    }
    for (int i = 0; i < scene.points.size; i++) {
        scene.setPoint(i, 0, 0, 2);
        scene.points.get(i).views.add(0);
        if (i % 2 == 0)
            scene.points.get(i).views.add(1);
        if (i % 3 == 0)
            scene.points.get(i).views.add(2);
    }
    // Call the function being tested and see if the expected number of points are matched to each view
    var alg = new GenerateStereoPairGraphFromScene();
    alg.matchPointsToViews(scene);
    assertEquals(3, alg.views.size);
    assertEquals(10, alg.views.get(0).pointing.size);
    assertEquals(5, alg.views.get(1).pointing.size);
    assertEquals(4, alg.views.get(2).pointing.size);
}
Also used : SceneStructureMetric(boofcv.abst.geo.bundle.SceneStructureMetric) Se3_F64(georegression.struct.se.Se3_F64) Test(org.junit.jupiter.api.Test)

Example 50 with SceneStructureMetric

use of boofcv.abst.geo.bundle.SceneStructureMetric in project BoofCV by lessthanoptimal.

the class TestGenerateStereoPairGraphFromScene method computePointingVector_Homogenous.

@Test
void computePointingVector_Homogenous() {
    var point = new Point3D_F64(0.5, -2, 31.0);
    var location = new Point3D_F64(0.5, -0.1, 1.6);
    var expected = new Vector3D_F64(location, point);
    expected.normalize();
    // Negative w needs to be handled carefully when normalizing. So test negative and positive
    for (double w : new double[] { -3.2, 3.2 }) {
        var scene = new SceneStructureMetric(true);
        scene.initialize(1, 1, 1);
        scene.setView(0, 0, true, SpecialEuclideanOps_F64.eulerXyz(-location.x, -location.y, -location.z, 0.1, -0.04, 0.02, null));
        scene.setPoint(0, point.x * w, point.y * w, point.z * w, w);
        var alg = new GenerateStereoPairGraphFromScene();
        Vector3D_F64 found = new Vector3D_F64();
        alg.computePointingVector(scene.getParentToView(0), scene.points.get(0), true, found);
        assertEquals(0.0, expected.distance(found), UtilEjml.TEST_F64);
    }
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) SceneStructureMetric(boofcv.abst.geo.bundle.SceneStructureMetric) Vector3D_F64(georegression.struct.point.Vector3D_F64) Test(org.junit.jupiter.api.Test)

Aggregations

SceneStructureMetric (boofcv.abst.geo.bundle.SceneStructureMetric)53 SceneObservations (boofcv.abst.geo.bundle.SceneObservations)21 Se3_F64 (georegression.struct.se.Se3_F64)20 Test (org.junit.jupiter.api.Test)14 VerbosePrint (org.ddogleg.struct.VerbosePrint)12 CameraPinhole (boofcv.struct.calib.CameraPinhole)11 Point3D_F64 (georegression.struct.point.Point3D_F64)8 SceneStructureCommon (boofcv.abst.geo.bundle.SceneStructureCommon)7 ArrayList (java.util.ArrayList)7 BundlePinholeSimplified (boofcv.alg.geo.bundle.cameras.BundlePinholeSimplified)6 Point2D_F64 (georegression.struct.point.Point2D_F64)6 CodecSceneStructureMetric (boofcv.alg.geo.bundle.CodecSceneStructureMetric)5 CameraPinholeBrown (boofcv.struct.calib.CameraPinholeBrown)5 BundleAdjustmentCamera (boofcv.abst.geo.bundle.BundleAdjustmentCamera)4 Point4D_F64 (georegression.struct.point.Point4D_F64)4 DogArray (org.ddogleg.struct.DogArray)4 TriangulateNViewsMetricH (boofcv.abst.geo.TriangulateNViewsMetricH)3 ConfigBundleAdjustment (boofcv.factory.geo.ConfigBundleAdjustment)3 Point2Transform2_F64 (boofcv.struct.distort.Point2Transform2_F64)3 TIntObjectHashMap (gnu.trove.map.hash.TIntObjectHashMap)3