Search in sources :

Example 6 with Point

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

the class TestPruneStructureFromSceneMetric method movePointBehindCameras.

/**
 * Take this many observations and turn into garbage observations
 */
private void movePointBehindCameras(int count) {
    DogArray<Point> points = structure.points;
    int[] indexes = new int[points.size];
    for (int i = 0; i < points.size; i++) {
        indexes[i] = i;
    }
    Point3D_F64 world = new Point3D_F64();
    for (int i = 0; i < count; i++) {
        int selected = rand.nextInt(points.size() - i);
        Point p = points.get(indexes[selected]);
        // swap the last element with the select one. The last element will be unselectable in future iterations
        int tmp = indexes[selected];
        indexes[selected] = indexes[points.size() - i - 1];
        indexes[points.size() - i - 1] = tmp;
        // all cameras lie along a line. This will move it behind all cameras
        p.get(world);
        world.z = -world.z;
        p.set(world.x, world.y, world.z);
    }
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) UtilPoint3D_F64(georegression.geometry.UtilPoint3D_F64) Point(boofcv.abst.geo.bundle.SceneStructureCommon.Point) Point(boofcv.abst.geo.bundle.SceneStructureCommon.Point)

Example 7 with Point

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

the class TestPruneStructureFromSceneMetric method pruneViews.

@Test
void pruneViews() {
    createPerfectScene();
    // original point count
    int pointCount = structure.points.size;
    int observationCount = observations.getObservationCount();
    // figure out the view with the least number of observations
    int viewWithLeast = -1;
    int leastCount = Integer.MAX_VALUE;
    for (int viewIdx = 0; viewIdx < observations.views.size; viewIdx++) {
        if (leastCount > observations.views.data[viewIdx].size()) {
            leastCount = observations.views.data[viewIdx].size();
            viewWithLeast = viewIdx;
        }
    }
    // remove a point just in case there is a tie
    observations.views.data[viewWithLeast].remove(8);
    leastCount -= 1;
    assertEquals(10, observations.views.size);
    var alg = new PruneStructureFromSceneMetric(structure, observations);
    // no change
    assertFalse(alg.pruneViews(leastCount - 1));
    assertEquals(10, observations.views.size);
    assertEquals(structure.views.size, observations.views.size);
    // Now prune views. Only one should be removed
    assertTrue(alg.pruneViews(leastCount));
    assertEquals(9, observations.views.size);
    assertEquals(structure.views.size, observations.views.size);
    // Points are not removed even if there is no view that can see them now
    assertEquals(structure.points.size, pointCount);
    // However the number of observations will be decreased
    assertTrue(observations.getObservationCount() < observationCount);
    // sanity check the modifications
    checkAllObservationsArePerfect();
}
Also used : Point(boofcv.abst.geo.bundle.SceneStructureCommon.Point) Test(org.junit.jupiter.api.Test)

Aggregations

Point (boofcv.abst.geo.bundle.SceneStructureCommon.Point)7 Test (org.junit.jupiter.api.Test)4 UtilPoint3D_F64 (georegression.geometry.UtilPoint3D_F64)3 Point3D_F64 (georegression.struct.point.Point3D_F64)3 Point2D_F64 (georegression.struct.point.Point2D_F64)2 Se3_F64 (georegression.struct.se.Se3_F64)2 ArrayList (java.util.ArrayList)1 DogArray_I32 (org.ddogleg.struct.DogArray_I32)1