Search in sources :

Example 1 with MetricCameraTriple

use of boofcv.alg.geo.selfcalib.MetricCameraTriple in project BoofCV by lessthanoptimal.

the class CommonGenerateMetricCameraTripleChecks method checkScene.

private void checkScene() {
    ModelGeneratorViews<MetricCameraTriple, AssociatedTriple, ElevateViewInfo> alg = createGenerator();
    assertEquals(3, alg.getNumberOfViews());
    for (int i = 0; i < 3; i++) {
        alg.setView(i, new ElevateViewInfo(800, 600, i));
    }
    assertTrue(alg.getMinimumPoints() > 0);
    var found = new MetricCameraTriple();
    List<AssociatedTriple> selected = new ArrayList<>();
    DogArray_I32 indexes = DogArray_I32.range(0, numFeatures);
    int countSuccess = 0;
    for (int trial = 0; trial < totalTrials; trial++) {
        // Randomly select different points each trial
        PrimitiveArrays.shuffle(indexes.data, 0, numFeatures, rand);
        selected.clear();
        for (int i = 0; i < alg.getMinimumPoints() + extraObservations; i++) {
            selected.add(observations3.get(indexes.get(i)));
        }
        // Compute the model
        if (!alg.generate(selected, found)) {
            continue;
        }
        countSuccess++;
        // System.out.println("Trial = "+trial);
        // Check results
        checkEquals(cameraA, found.view1);
        checkEquals(cameraB, found.view2);
        checkEquals(cameraC, found.view3);
        BoofTesting.assertEqualsToScaleS(truthView_1_to_i(1), found.view_1_to_2, 1e-2, 1e-3);
        BoofTesting.assertEqualsToScaleS(truthView_1_to_i(2), found.view_1_to_3, 1e-2, 1e-3);
    }
    // System.out.println("Passed "+countSuccess+" / "+totalTrials);
    assertTrue(minimumFractionSuccess * totalTrials <= countSuccess, "Failed " + (totalTrials - countSuccess) + " min " + (minimumFractionSuccess * totalTrials - countSuccess));
}
Also used : MetricCameraTriple(boofcv.alg.geo.selfcalib.MetricCameraTriple) AssociatedTriple(boofcv.struct.geo.AssociatedTriple) ArrayList(java.util.ArrayList) DogArray_I32(org.ddogleg.struct.DogArray_I32) ElevateViewInfo(boofcv.struct.calib.ElevateViewInfo)

Aggregations

MetricCameraTriple (boofcv.alg.geo.selfcalib.MetricCameraTriple)1 ElevateViewInfo (boofcv.struct.calib.ElevateViewInfo)1 AssociatedTriple (boofcv.struct.geo.AssociatedTriple)1 ArrayList (java.util.ArrayList)1 DogArray_I32 (org.ddogleg.struct.DogArray_I32)1