use of boofcv.alg.similar.SimilarImagesFromTracks.Match in project BoofCV by lessthanoptimal.
the class TestSimilarImagesFromTracks method findRelatedPastFrames_matched.
/**
* All but one observation match
*/
@Test
void findRelatedPastFrames_matched() {
var tracker = new MockTracker();
SimilarImagesFromTracks<PointTrack> alg = createTracker();
// create two frames with common observations
for (int i = 0; i < 2; i++) {
tracker.process(null);
alg.createFrameSaveObservations(tracker.getActiveTracks(null), tracker.getFrameID());
}
// make the most recent incompatible with the previous
Frame current = alg.frames.get(1);
current.id_to_index.remove(15);
current.ids[15] = 115;
current.id_to_index.put(115, 15);
// randomize the ID order to make things more interesting. This will mess up which observation they point to
PrimitiveArrays.shuffle(current.ids, 0, current.ids.length, rand);
alg.findRelatedPastFrames(current);
for (int i = 0; i < alg.frames.size; i++) {
Frame f = alg.frames.get(i);
assertEquals(1, f.matches.size());
Match matches = alg.connections.get(0);
assertEquals(19, matches.size());
assertNotSame(matches.frameSrc, matches.frameDst);
assertTrue(matches.frameSrc == f || matches.frameDst == f);
// checks to see if the ids are consistent is done in the system check above
}
}
use of boofcv.alg.similar.SimilarImagesFromTracks.Match in project BoofCV by lessthanoptimal.
the class TestSimilarImagesFromTracks method createFullyLoaded.
/**
* Fill in the algorithm with dummy values to test the contracts
*/
@Override
public SimilarImagesFromTracks createFullyLoaded() {
int numFeatures = 11;
SimilarImagesFromTracks<PointTrack> alg = createTracker();
alg.initialize(200, 210);
alg.frames.resize(5);
for (int i = 0; i < alg.frames.size; i++) {
SimilarImagesFromTracks.Frame f = alg.frames.get(i);
f.frameID = "" + i;
alg.frameMap.put(f.frameID, f);
f.initActive(numFeatures);
for (int j = 0; j < i; j++) {
Match m = alg.connections.grow();
m.init(numFeatures);
SimilarImagesFromTracks.Frame r = alg.frames.get(j);
f.related.add(r);
r.related.add(f);
f.matches.add(m);
r.matches.add(m);
m.frameSrc = f;
m.frameDst = r;
for (int k = 0; k < m.size(); k++) {
// Randomize the values make it obvious if the feature src/dst order is respected
m.src[k] = rand.nextInt();
m.dst[k] = rand.nextInt();
}
}
}
return alg;
}
Aggregations