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