use of boofcv.abst.tracker.PointTrack in project BoofCV by lessthanoptimal.
the class TestPointTrackerPerfectCloud method multipleCallsStatic.
/**
* The view isn't moving and it's viewing the same objects
*/
@Test
void multipleCallsStatic() {
var tracker = new PointTrackerPerfectCloud<>();
tracker.setCamera(new CameraPinhole(200, 200, 0, 200, 200, 400, 400));
tracker.cloud.add(new Point3D_F64(0, 0, 2));
tracker.cloud.add(new Point3D_F64(0.5, 0, 3));
tracker.cloud.add(new Point3D_F64(0, 0.5, -2));
tracker.process(null);
tracker.spawnTracks();
DogArray<Point2D_F64> expected = new DogArray<>(Point2D_F64::new);
tracker.getNewTracks(null).forEach(t -> expected.grow().setTo(t.pixel));
for (int i = 0; i < 5; i++) {
tracker.process(null);
assertEquals(2, tracker.getTotalActive());
assertEquals(0, tracker.getTotalInactive());
assertTrue(tracker.getDroppedTracks(null).isEmpty());
List<PointTrack> active = tracker.getActiveTracks(null);
BoofMiscOps.forIdx(active, (idx, t) -> {
assertEquals(0.0, t.pixel.distance(expected.get(idx)), UtilEjml.TEST_F64);
});
}
}
use of boofcv.abst.tracker.PointTrack in project BoofCV by lessthanoptimal.
the class WrapVisOdomMonoStereoDepthPnP method getTrackPixel.
@Override
public void getTrackPixel(int index, Point2D_F64 pixel) {
// If this throws a null pointer exception then that means there's a bug. The only way a visible track
// could have a null trackerTrack is if the trackerTrack was dropped. In that case it's no longer visible
PointTrack track = Objects.requireNonNull(alg.getVisibleTracks().get(index).visualTrack);
pixel.setTo(track.pixel);
}
use of boofcv.abst.tracker.PointTrack in project BoofCV by lessthanoptimal.
the class ImageMotionPointTrackerKey method changeKeyFrame.
/**
* Change the current frame into the keyframe. p1 location of existing tracks is set to
* their current location and new tracks are spawned. Reference frame transformations are also updated
*/
public void changeKeyFrame() {
final long frameID = tracker.getFrameID();
// drop all inactive tracks since their location is unknown in the current frame
List<PointTrack> inactive = tracker.getInactiveTracks(null);
for (PointTrack l : inactive) {
// lint:forbidden ignore_line
tracker.dropTrack(l);
}
// set the keyframe for active tracks as their current location
List<PointTrack> active = tracker.getActiveTracks(null);
for (PointTrack l : active) {
// lint:forbidden ignore_line
AssociatedPairTrack p = l.getCookie();
p.p1.setTo(l.pixel);
p.lastUsed = frameID;
}
tracker.spawnTracks();
List<PointTrack> spawned = tracker.getNewTracks(null);
for (PointTrack l : spawned) {
// lint:forbidden ignore_line
AssociatedPairTrack p = l.getCookie();
if (p == null) {
l.cookie = p = new AssociatedPairTrack();
// little bit of trickery here. Save the reference so that the point
// in the current frame is updated for free as PointTrack is
p.p2 = l.pixel;
}
p.p1.setTo(l.pixel);
p.lastUsed = frameID;
}
worldToKey.setTo(worldToCurr);
keyToCurr.reset();
keyFrame = true;
}
use of boofcv.abst.tracker.PointTrack in project BoofCV by lessthanoptimal.
the class WrapImageMotionPtkSmartRespawn method checkInitialize.
private void checkInitialize() {
if (!inliersMarked) {
inliersMarked = true;
List<PointTrack> active = alg.getMotion().getTracker().getActiveTracks(null);
allTracks.clear();
long tick = getFrameID();
inliers.resize(active.size());
for (int i = 0; i < active.size(); i++) {
PointTrack t = active.get(i);
AssociatedPairTrack info = t.getCookie();
allTracks.add(t.pixel);
// if it was used in the previous update then it is in the inlier set
inliers.data[i] = info.lastUsed == tick;
}
}
}
use of boofcv.abst.tracker.PointTrack in project BoofCV by lessthanoptimal.
the class WrapVisOdomDualTrackPnP method getTrackPixel.
@Override
public void getTrackPixel(int index, Point2D_F64 pixel) {
// If this throws a null pointer exception then that means there's a bug. The only way a visible track
// could have a null trackerTrack is if the trackerTrack was dropped. In that case it's no longer visible
PointTrack track = Objects.requireNonNull(visualOdometry.getVisibleTracks().get(index).visualTrack);
pixel.setTo(track.pixel);
}
Aggregations