use of boofcv.alg.mvs.StereoPairGraph in project BoofCV by lessthanoptimal.
the class TestGenerateStereoPairGraphFromScene method allTogether.
/**
* Simple test where viewA and viewB only share very far away points and should have a low score. A and C
* share some much closer points and should have a good score.
*/
@Test
void allTogether() {
var viewToId = new TIntObjectHashMap<String>();
var scene = new SceneStructureMetric(false);
scene.initialize(3, 3, 10);
for (int i = 0; i < 3; i++) {
viewToId.put(i, "" + (i + 1));
scene.setView(i, i, true, new Se3_F64());
scene.setCamera(i, true, new CameraPinhole(200, 200, 0, 150, 150, 300, 300));
scene.motions.get(i).motion.T.x = i;
}
// Create the points far away
for (int i = 0; i < 5; i++) {
scene.setPoint(i, 0, 0, 1e4);
scene.points.get(i).views.setTo(0, 1);
}
// Add the up close points
for (int i = 5; i < 10; i++) {
scene.setPoint(i, 0, 0, 4);
scene.points.get(i).views.setTo(0, 2);
}
var alg = new GenerateStereoPairGraphFromScene();
alg.process(viewToId, scene);
StereoPairGraph found = alg.getStereoGraph();
assertEquals(3, found.vertexes.size());
StereoPairGraph.Vertex vA = Objects.requireNonNull(found.vertexes.get("1"));
StereoPairGraph.Vertex vB = Objects.requireNonNull(found.vertexes.get("2"));
StereoPairGraph.Vertex vC = Objects.requireNonNull(found.vertexes.get("3"));
assertEquals(0, vA.indexSba);
assertEquals(1, vB.indexSba);
assertEquals(2, vC.indexSba);
assertEquals(2, vA.pairs.size());
assertEquals(1, vB.pairs.size());
assertEquals(1, vC.pairs.size());
double quality_a_b = vA.pairs.get(0).quality3D;
double quality_a_c = vA.pairs.get(1).quality3D;
assertTrue(quality_a_c > quality_a_b * 2);
assertTrue(quality_a_b > 0.0 && quality_a_b <= 1.0);
assertTrue(quality_a_c > 0.0 && quality_a_c <= 1.0);
}
Aggregations