Search in sources :

Example 36 with PointTrack

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);
        });
    }
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) PointTrack(boofcv.abst.tracker.PointTrack) Point2D_F64(georegression.struct.point.Point2D_F64) CameraPinhole(boofcv.struct.calib.CameraPinhole) DogArray(org.ddogleg.struct.DogArray) Test(org.junit.jupiter.api.Test)

Example 37 with PointTrack

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);
}
Also used : PointTrack(boofcv.abst.tracker.PointTrack)

Example 38 with PointTrack

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;
}
Also used : PointTrack(boofcv.abst.tracker.PointTrack)

Example 39 with PointTrack

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;
        }
    }
}
Also used : AssociatedPairTrack(boofcv.alg.sfm.d2.AssociatedPairTrack) PointTrack(boofcv.abst.tracker.PointTrack)

Example 40 with PointTrack

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);
}
Also used : PointTrack(boofcv.abst.tracker.PointTrack)

Aggregations

PointTrack (boofcv.abst.tracker.PointTrack)44 Test (org.junit.jupiter.api.Test)11 Frame (boofcv.alg.similar.SimilarImagesFromTracks.Frame)5 ArrayList (java.util.ArrayList)5 BTrack (boofcv.alg.sfm.d3.structure.VisOdomBundleAdjustment.BTrack)3 AssociatedIndex (boofcv.struct.feature.AssociatedIndex)3 Point2D_F64 (georegression.struct.point.Point2D_F64)3 Point3D_F64 (georegression.struct.point.Point3D_F64)3 DetectDescribePoint (boofcv.abst.feature.detdesc.DetectDescribePoint)2 Match (boofcv.alg.similar.SimilarImagesFromTracks.Match)2 CameraPinhole (boofcv.struct.calib.CameraPinhole)2 GrayU8 (boofcv.struct.image.GrayU8)2 BufferedImage (java.awt.image.BufferedImage)2 DogArray (org.ddogleg.struct.DogArray)2 ScoreAssociateEuclideanSq (boofcv.abst.feature.associate.ScoreAssociateEuclideanSq)1 ConfigPointDetector (boofcv.abst.feature.detect.interest.ConfigPointDetector)1 AssociatedPairTrack (boofcv.alg.sfm.d2.AssociatedPairTrack)1 VisOdomMonoPlaneInfinity (boofcv.alg.sfm.d3.VisOdomMonoPlaneInfinity)1 ConfigPKlt (boofcv.alg.tracker.klt.ConfigPKlt)1 ImagePanel (boofcv.gui.image.ImagePanel)1