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);
}
}
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();
}
Aggregations