use of boofcv.alg.similar.SimilarImagesFromTracks.Frame in project BoofCV by lessthanoptimal.
the class TestSimilarImagesFromTracks method findRelatedPastFrames_no_common.
/**
* No common features so no match should be created.
*/
@Test
void findRelatedPastFrames_no_common() {
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.clear();
for (int i = 0; i < current.featureCount(); i++) {
current.ids[i] = 100 + i;
current.id_to_index.put(current.ids[i], i);
}
alg.findRelatedPastFrames(current);
for (int i = 0; i < alg.frames.size; i++) {
assertEquals(0, alg.frames.get(i).matches.size());
}
}
use of boofcv.alg.similar.SimilarImagesFromTracks.Frame in project BoofCV by lessthanoptimal.
the class TestSimilarImagesFromTracks method minimumCommonTracks.
/**
* Nake sure that this configuration is used correctly internally
*/
@Test
void minimumCommonTracks() {
var tracker = new MockTracker();
tracker.numTracks = 20;
SimilarImagesFromTracks<PointTrack> alg = createTracker();
alg.initialize(30, 40);
// every frame there is one less track in common. Since there are 20 tracks, 18 means it should
// be matched with 2 frames within its radius
alg.minimumCommonTracks.setFixed(18);
for (int i = 0; i < 6; i++) {
tracker.process(null);
// this is what causes N-1 features to be in common between frames
tracker.offsetID++;
alg.processFrame(tracker.getActiveTracks(null), tracker.getFrameID());
if (i <= 2)
continue;
// Check the most recently added frame
SimilarImagesFromTracks.Frame frame = alg.frames.getTail();
assertEquals(2, frame.related.size());
}
// double check that it's matching them symmetrically
assertEquals(4, alg.frames.get(3).related.size());
}
use of boofcv.alg.similar.SimilarImagesFromTracks.Frame in project BoofCV by lessthanoptimal.
the class TestSimilarImagesFromTracks method createFrameSaveObservations.
@Test
void createFrameSaveObservations() {
var tracker = new MockTracker();
SimilarImagesFromTracks<PointTrack> alg = createTracker();
assertEquals(0, alg.frames.size);
tracker.process(null);
alg.createFrameSaveObservations(tracker.getActiveTracks(null), tracker.getFrameID());
assertEquals(1, alg.frameMap.size());
assertEquals(1, alg.frames.size);
Frame frame = alg.frames.get(0);
assertEquals("0", frame.frameID);
assertSame(frame, alg.frameMap.get(frame.frameID));
assertEquals(tracker.numTracks, frame.featureCount());
var foundPixel = new Point2D_F64();
for (int i = 0; i < frame.featureCount(); i++) {
assertEquals(i, frame.getID(i));
frame.getPixel(i, foundPixel);
assertEquals(i, foundPixel.x, UtilEjml.TEST_F64);
assertEquals(i + 1, foundPixel.y, UtilEjml.TEST_F64);
}
// see if it can handle adding another frame
tracker.process(null);
alg.createFrameSaveObservations(tracker.getActiveTracks(null), tracker.getFrameID());
assertEquals(2, alg.frameMap.size());
assertEquals(2, alg.frames.size);
frame = alg.frames.get(1);
assertEquals("1", frame.frameID);
assertSame(frame, alg.frameMap.get(frame.frameID));
assertEquals(tracker.numTracks, frame.featureCount());
}
use of boofcv.alg.similar.SimilarImagesFromTracks.Frame 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
}
}
Aggregations