Search in sources :

Example 1 with View

use of boofcv.alg.structure.PairwiseImageGraph.View in project BoofCV by lessthanoptimal.

the class TestExpandByOneView method createListOfValid.

@Test
void createListOfValid() {
    var working = new SceneWorkingGraph();
    var graph = new PairwiseImageGraph();
    SceneWorkingGraph.Camera camera = working.addCamera(2);
    View seed = graph.createNode("A");
    for (int i = 0; i < 10; i++) {
        View viewI = graph.createNode("" + i);
        Motion mA = graph.connect(seed, viewI);
        // is3D and being known are at different frequencies and will only intersect twice
        mA.is3D = i % 2 == 0;
        if (i % 3 == 0)
            working.addView(viewI, camera);
    }
    var alg = new ChildProjectiveExpandByOneView();
    alg.workGraph = working;
    List<Motion> valid = new ArrayList<>();
    alg.createListOfValid(seed, valid);
    assertEquals(2, valid.size());
}
Also used : Motion(boofcv.alg.structure.PairwiseImageGraph.Motion) SceneWorkingGraph(boofcv.alg.structure.SceneWorkingGraph) ArrayList(java.util.ArrayList) PairwiseImageGraph(boofcv.alg.structure.PairwiseImageGraph) View(boofcv.alg.structure.PairwiseImageGraph.View) Test(org.junit.jupiter.api.Test)

Example 2 with View

use of boofcv.alg.structure.PairwiseImageGraph.View in project BoofCV by lessthanoptimal.

the class TestProjectiveInitializeAllCommon method perfect_connections_2.

/**
 * Perfect scene with 2 connections. This is the simplest case
 */
@Test
void perfect_connections_2() {
    // NOTES: Using regular pixels maxed out at 12
    // With zero centering maxed out at 14
    var alg = new ProjectiveInitializeAllCommon();
    for (int seedIdx = 0; seedIdx < 3; seedIdx++) {
        var dbSimilar = new MockLookupSimilarImagesRealistic().pathCircle(4, 2);
        var dbCams = new MockLookUpCameraInfo(dbSimilar.intrinsic);
        PairwiseImageGraph graph = dbSimilar.createPairwise();
        View seed = graph.nodes.get(seedIdx);
        var seedConnIdx = DogArray_I32.array(0, 2);
        // in this specific scenario all features are visible by all frames
        var seedFeatsIdx = DogArray_I32.range(0, dbSimilar.numFeatures);
        // however not all features are in the inlier set. Remove all features not in inlier set
        removeConnectionOutliers(seed, seedFeatsIdx);
        // Reconstruct the projective scene
        assertTrue(alg.projectiveSceneN(dbSimilar, dbCams, seed, seedFeatsIdx, seedConnIdx));
        // test results
        checkReconstruction(alg, dbSimilar, seedConnIdx, reprojectionTol);
        checkCameraMatrices(alg, dbSimilar);
    }
}
Also used : View(boofcv.alg.structure.PairwiseImageGraph.View) Test(org.junit.jupiter.api.Test)

Example 3 with View

use of boofcv.alg.structure.PairwiseImageGraph.View in project BoofCV by lessthanoptimal.

the class TestProjectiveInitializeAllCommon method createStructureLookUpTables.

@Test
void createStructureLookUpTables() {
    int offset = 5;
    var db = new MockLookupSimilarImages(4, 0xDEADBEEF);
    var alg = new ProjectiveInitializeAllCommon();
    alg.utils.ransac = new MockRansac(offset, db.feats3D.size() - offset);
    alg.utils.dbSimilar = db;
    alg.utils.P1.setTo(db.listCameraMatrices.get(0));
    alg.utils.P2.setTo(db.listCameraMatrices.get(1));
    alg.utils.P3.setTo(db.listCameraMatrices.get(3));
    alg.utils.commonIdx.setTo(DogArray_I32.range(0, db.feats3D.size()));
    // order shouldn't mattter
    PrimitiveArrays.shuffle(alg.utils.commonIdx.data, 0, alg.utils.commonIdx.size, rand);
    View seed = db.graph.nodes.get(0);
    alg.inlierIndexes.resize(3);
    alg.createStructureLookUpTables(seed);
    // Check to see if inlier indexes are correct
    int numInliers = db.feats3D.size() - offset;
    DogArray_I32 inlierToSeed = alg.inlierIndexes.get(0);
    assertEquals(numInliers, inlierToSeed.size);
    for (int i = 0; i < numInliers; i++) {
        assertEquals(alg.utils.commonIdx.get(i + offset), inlierToSeed.get(i));
    }
    // mapping from seed features to structure features
    for (int i = 0; i < db.feats3D.size(); i++) {
        assertEquals(i < offset ? -1 : i - offset, alg.seedToStructure.get(alg.utils.commonIdx.get(i)));
    }
}
Also used : DogArray_I32(org.ddogleg.struct.DogArray_I32) View(boofcv.alg.structure.PairwiseImageGraph.View) Test(org.junit.jupiter.api.Test)

Example 4 with View

use of boofcv.alg.structure.PairwiseImageGraph.View in project BoofCV by lessthanoptimal.

the class TestProjectiveInitializeAllCommon method checkConfiguration.

private void checkConfiguration(ProjectiveInitializeAllCommon alg, MockLookupSimilarImages dbSimilar, MockLookUpCameraInfo dbCams, boolean threeViews, boolean sba, boolean scale, double reprojectionTol) {
    alg.utils.configConvergeSBA.maxIterations = sba ? 50 : -1;
    alg.utils.configScaleSBA = scale;
    View seed = dbSimilar.graph.nodes.get(0);
    var seedFeatsIdx = new DogArray_I32();
    var seedConnIdx = threeViews ? DogArray_I32.array(0, 2) : DogArray_I32.array(1, 2, 3);
    // Give a subset as a test to see if the size is being properly pass down the chain
    int offset = 0;
    int numFeatures = dbSimilar.feats3D.size() - offset;
    for (int i = offset; i < numFeatures; i++) {
        seedFeatsIdx.add(i);
    }
    // order should not matter
    PrimitiveArrays.shuffle(seedFeatsIdx.data, 0, seedFeatsIdx.size, rand);
    // Reconstruct the projective scene
    assertTrue(alg.projectiveSceneN(dbSimilar, dbCams, seed, seedFeatsIdx, seedConnIdx));
    // test results
    checkReconstruction(alg, dbSimilar, seedConnIdx, numFeatures, reprojectionTol);
}
Also used : DogArray_I32(org.ddogleg.struct.DogArray_I32) View(boofcv.alg.structure.PairwiseImageGraph.View)

Example 5 with View

use of boofcv.alg.structure.PairwiseImageGraph.View in project BoofCV by lessthanoptimal.

the class TestProjectiveInitializeAllCommon method scoreTripleView_Prefer3D.

/**
 * See if it scores a set of three views higher if they have stronger 3D information
 */
@Test
void scoreTripleView_Prefer3D() {
    var alg = new ProjectiveInitializeAllCommon();
    View seedA = new View();
    View viewB = new View();
    View viewC = new View();
    Motion motionAB = new Motion();
    motionAB.src = seedA;
    motionAB.dst = viewB;
    motionAB.score3D = 2.0;
    Motion motionAC = new Motion();
    motionAC.src = viewC;
    motionAC.dst = seedA;
    motionAC.score3D = 1000.0;
    Motion motionBC = new Motion();
    motionBC.src = viewC;
    motionBC.dst = viewB;
    motionBC.score3D = 20.0;
    seedA.connections.add(motionAB);
    viewB.connections.add(motionAB);
    seedA.connections.add(motionAC);
    viewC.connections.add(motionAC);
    viewB.connections.add(motionBC);
    viewC.connections.add(motionBC);
    double score0 = alg.scoreTripleView(seedA, viewB, viewC);
    // make it have a stronger 3D score and see if this is reflected
    motionAB.score3D *= 2.0;
    assertTrue(alg.scoreTripleView(seedA, viewB, viewC) > score0);
    // now a worse score
    motionAB.score3D *= 0.1;
    assertTrue(alg.scoreTripleView(seedA, viewB, viewC) < score0);
}
Also used : Motion(boofcv.alg.structure.PairwiseImageGraph.Motion) View(boofcv.alg.structure.PairwiseImageGraph.View) Test(org.junit.jupiter.api.Test)

Aggregations

View (boofcv.alg.structure.PairwiseImageGraph.View)20 Test (org.junit.jupiter.api.Test)9 Motion (boofcv.alg.structure.PairwiseImageGraph.Motion)8 VerbosePrint (org.ddogleg.struct.VerbosePrint)8 DogArray_I32 (org.ddogleg.struct.DogArray_I32)6 SceneObservations (boofcv.abst.geo.bundle.SceneObservations)4 ArrayList (java.util.ArrayList)4 Point2D_F64 (georegression.struct.point.Point2D_F64)3 DMatrixRMaj (org.ejml.data.DMatrixRMaj)3 PairwiseImageGraph (boofcv.alg.structure.PairwiseImageGraph)2 SceneWorkingGraph (boofcv.alg.structure.SceneWorkingGraph)2 CompatibleProjectiveHomography (boofcv.alg.geo.pose.CompatibleProjectiveHomography)1 AssociatedIndex (boofcv.struct.feature.AssociatedIndex)1 AssociatedTriple (boofcv.struct.geo.AssociatedTriple)1 UtilPoint3D_F64 (georegression.geometry.UtilPoint3D_F64)1 Point3D_F64 (georegression.struct.point.Point3D_F64)1 Se3_F64 (georegression.struct.se.Se3_F64)1 Rodrigues_F64 (georegression.struct.so.Rodrigues_F64)1