use of boofcv.abst.tracker.PointTrack in project BoofCV by lessthanoptimal.
the class MonoPlaneInfinity_to_MonocularPlaneVisualOdometry method isTrackInlier.
@Override
public boolean isTrackInlier(int index) {
if (active == null)
active = alg.getTracker().getActiveTracks(null);
PointTrack t = active.get(index);
VisOdomMonoPlaneInfinity.VoTrack v = t.getCookie();
return v.lastInlier == alg.getFrameID();
}
use of boofcv.abst.tracker.PointTrack in project BoofCV by lessthanoptimal.
the class TestSimilarImagesTrackThenMatch method simpleLoop.
/**
* Faking the inputs, see if it can attack all frames to the first frame when tracking fails
*/
@Test
void simpleLoop() {
int numViews = 6;
var alg = new SimilarImagesTrackThenMatch<>(new DummyDetector(), new AssociateDescriptionHashSets<>(FactoryAssociation.greedy(null, new ScoreAssociateEuclideanSq.F32())), new DummyRecognizerLoop(numViews), () -> new PackedTupleArray_F32(1));
// Remove any restriction on how many frames need to have past
alg.minimumRecognizeDistance = 0;
alg.initialize(10, 20);
// A dummy image
GrayU8 image = new GrayU8(10, 20);
// Create a set of tracks
int numTracks = 20;
DogArray<PointTrack> tracks = new DogArray<>(PointTrack::new);
for (int i = 0; i < numTracks; i++) {
PointTrack t = tracks.grow();
t.pixel.setTo(i, 21 * (i + 1));
t.featureId = i;
}
// the frame-to-frame tracker will fail but the recognizer will match everything to frame 0
for (int frameID = 0; frameID < numViews; frameID++) {
alg.processFrame(image, tracks.toList(), frameID);
for (int i = 0; i < tracks.size; i++) {
PointTrack t = tracks.get(i);
t.pixel.setTo((frameID + 1) * numTracks, 21 * (i + 1));
// this will prevent the tracker from matching frames
t.featureId = i + (frameID + 1) * numTracks;
}
}
// Has to be called after frame to frame tracking
alg.finishedTracking();
// Storage for association results
DogArray<AssociatedIndex> pairs = new DogArray<>(AssociatedIndex::new);
List<String> listImages = alg.getImageIDs();
List<String> listSimilar = new ArrayList<>();
// everything should be matched to the first frame
alg.findSimilar(listImages.get(0), null, listSimilar);
assertEquals(numViews - 1, listSimilar.size());
for (String similarID : listSimilar) {
assertTrue(alg.lookupAssociated(similarID, pairs));
assertEquals(numTracks, pairs.size);
}
// Other frames shouldn't be matched with each other
for (int frameIdx = 1; frameIdx < 6; frameIdx++) {
alg.findSimilar(listImages.get(frameIdx), null, listSimilar);
assertEquals(1, listSimilar.size());
}
}
use of boofcv.abst.tracker.PointTrack 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.abst.tracker.PointTrack 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.abst.tracker.PointTrack 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());
}
Aggregations