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