Search in sources :

Example 81 with DogArray_I32

use of org.ddogleg.struct.DogArray_I32 in project BoofCV by lessthanoptimal.

the class AssociateDescriptionHashSets method associate.

/**
 * Associates each set of features independently then puts them back into a single list for output
 */
@Override
public void associate() {
    if (sets.size <= 0)
        throw new IllegalArgumentException("You must initialize first with the number of sets");
    // System.out.println("assoc sets.size="+sets.size);
    // reset data structures
    matches.reset();
    unassociatedSrc.reset();
    unassociatedDst.reset();
    // Don't need to go through every single set. The largest list will have to contain the entire set
    // of common feature sets
    DogArray_I32 setList = setsAddedBySrc.size > setsAddedByDst.size ? setsAddedBySrc : setsAddedByDst;
    for (int setListIdx = 0; setListIdx < setList.size; setListIdx++) {
        int setIdx = setList.get(setListIdx);
        SetStruct set = sets.get(setIdx);
        // See if it's impossible for there to be a match
        if (set.src.size == 0 || set.dst.size == 0) {
            // TODO save unassociated
            continue;
        }
        // System.out.printf(" set[%d] src=%d dst=%d\n", setIdx, set.src.size, set.dst.size);
        // Associate features inside this set
        associator.setSource(set.src);
        associator.setDestination(set.dst);
        associator.associate();
        saveSetAssociateResults(set);
    }
}
Also used : DogArray_I32(org.ddogleg.struct.DogArray_I32)

Example 82 with DogArray_I32

use of org.ddogleg.struct.DogArray_I32 in project BoofCV by lessthanoptimal.

the class BaseAssociateSets method saveSetAssociateResults.

/**
 * After associating a set run association these processes and saves the results
 */
protected void saveSetAssociateResults(SetStruct set) {
    // used to store the size of the structure from a previous iteration
    int before = matches.size;
    // Copy the results from being local to this set into the original input indexes
    FastAccess<AssociatedIndex> setMatches = _associator.getMatches();
    matches.resize(matches.size + setMatches.size);
    for (int assocIdx = 0; assocIdx < setMatches.size; assocIdx++) {
        AssociatedIndex sa = setMatches.get(assocIdx);
        int inputIdxSrc = set.indexSrc.data[sa.src];
        int inputIdxDst = set.indexDst.data[sa.dst];
        matches.data[before + assocIdx].setTo(inputIdxSrc, inputIdxDst, sa.fitScore);
    }
    // Copy unassociated indexes over and updated indexes to input indexes
    DogArray_I32 setUnassociatedSrc = _associator.getUnassociatedSource();
    before = unassociatedSrc.size;
    unassociatedSrc.extend(before + setUnassociatedSrc.size);
    for (int i = 0; i < setUnassociatedSrc.size; i++) {
        unassociatedSrc.data[before + i] = set.indexSrc.data[setUnassociatedSrc.get(i)];
    }
    DogArray_I32 setUnassociatedDst = _associator.getUnassociatedDestination();
    before = unassociatedDst.size;
    unassociatedDst.extend(before + setUnassociatedDst.size);
    for (int i = 0; i < setUnassociatedDst.size; i++) {
        unassociatedDst.data[before + i] = set.indexDst.data[setUnassociatedDst.get(i)];
    }
}
Also used : DogArray_I32(org.ddogleg.struct.DogArray_I32) AssociatedIndex(boofcv.struct.feature.AssociatedIndex)

Example 83 with DogArray_I32

use of org.ddogleg.struct.DogArray_I32 in project BoofCV by lessthanoptimal.

the class WrapAssociateGreedy method associate.

@Override
public void associate() {
    if (listSrc == null)
        throw new IllegalArgumentException("source features not specified");
    if (listDst == null)
        throw new IllegalArgumentException("destination features not specified");
    unassocSrc.reset();
    alg.associate(listSrc, listDst);
    DogArray_I32 pairs = alg.getPairs();
    DogArray_F64 score = alg.getFitQuality();
    matches.reset();
    for (int i = 0; i < listSrc.size; i++) {
        int dst = pairs.data[i];
        if (dst >= 0)
            matches.grow().setTo(i, dst, score.data[i]);
        else
            unassocSrc.add(i);
    }
}
Also used : DogArray_I32(org.ddogleg.struct.DogArray_I32) DogArray_F64(org.ddogleg.struct.DogArray_F64)

Example 84 with DogArray_I32

use of org.ddogleg.struct.DogArray_I32 in project BoofCV by lessthanoptimal.

the class StandardAssociateDescriptionChecks method checkUnassociatedLists_emptySrc.

@Test
void checkUnassociatedLists_emptySrc() {
    init();
    AssociateDescription<Desc> alg = createAssociate();
    listDst.add(c(1 + 0.1));
    listDst.add(c(2 + 0.05));
    listDst.add(c(3 + 0.05));
    // can't be paired with anything
    listDst.add(c(20));
    // set threshold so that one pair won't be considered
    alg.setMaxScoreThreshold(distanceIsSquared ? 0.07 * 0.07 : 0.07);
    alg.setSource(listSrc);
    alg.setDestination(listDst);
    alg.associate();
    assertEquals(0, alg.getMatches().size);
    assertEquals(0, alg.getUnassociatedSource().size);
    assertEquals(4, alg.getUnassociatedDestination().size);
    DogArray_I32 unassociated = alg.getUnassociatedDestination();
    unassociated.sort();
    for (int i = 0; i < unassociated.size; i++) {
        assertEquals(i, unassociated.get(i));
    }
}
Also used : DogArray_I32(org.ddogleg.struct.DogArray_I32) Test(org.junit.jupiter.api.Test)

Example 85 with DogArray_I32

use of org.ddogleg.struct.DogArray_I32 in project BoofCV by lessthanoptimal.

the class StandardAssociateDescriptionChecks method checkUnassociatedLists_emptyDst.

@Test
void checkUnassociatedLists_emptyDst() {
    init();
    AssociateDescription<Desc> alg = createAssociate();
    listSrc.add(c(1));
    listSrc.add(c(2));
    listSrc.add(c(3));
    // set threshold so that one pair won't be considered
    alg.setMaxScoreThreshold(distanceIsSquared ? 0.07 * 0.07 : 0.07);
    alg.setSource(listSrc);
    alg.setDestination(listDst);
    alg.associate();
    assertEquals(0, alg.getMatches().size);
    assertEquals(3, alg.getUnassociatedSource().size);
    assertEquals(0, alg.getUnassociatedDestination().size);
    DogArray_I32 unassociated = alg.getUnassociatedSource();
    unassociated.sort();
    for (int i = 0; i < unassociated.size; i++) {
        assertEquals(i, unassociated.get(i));
    }
}
Also used : DogArray_I32(org.ddogleg.struct.DogArray_I32) Test(org.junit.jupiter.api.Test)

Aggregations

DogArray_I32 (org.ddogleg.struct.DogArray_I32)192 Test (org.junit.jupiter.api.Test)73 Point2D_I32 (georegression.struct.point.Point2D_I32)24 ArrayList (java.util.ArrayList)21 Point2D_F64 (georegression.struct.point.Point2D_F64)17 DogArray (org.ddogleg.struct.DogArray)17 TupleDesc_F64 (boofcv.struct.feature.TupleDesc_F64)15 GrayS32 (boofcv.struct.image.GrayS32)10 VerbosePrint (org.ddogleg.struct.VerbosePrint)7 View (boofcv.alg.structure.PairwiseImageGraph.View)6 AssociatedIndex (boofcv.struct.feature.AssociatedIndex)6 GrayI (boofcv.struct.image.GrayI)5 Point3D_F64 (georegression.struct.point.Point3D_F64)5 GrowArray (pabeles.concurrency.GrowArray)5 DetectDescribePoint (boofcv.abst.feature.detdesc.DetectDescribePoint)4 BTrack (boofcv.alg.sfm.d3.structure.VisOdomBundleAdjustment.BTrack)4 AssociatedTripleIndex (boofcv.struct.feature.AssociatedTripleIndex)4 SceneObservations (boofcv.abst.geo.bundle.SceneObservations)3 SceneWorkingGraph (boofcv.alg.structure.SceneWorkingGraph)3 ConfigAssociateGreedy (boofcv.factory.feature.associate.ConfigAssociateGreedy)3