Search in sources :

Example 31 with PointTrack

use of boofcv.abst.tracker.PointTrack in project BoofCV by lessthanoptimal.

the class SelectFramesForReconstruction3D method copyTrackResultsIntoCurrentFrame.

/**
 * Copies results from image-to-image tracker into the 'currentFrame'
 */
protected void copyTrackResultsIntoCurrentFrame(T image) {
    descriptor.setImage(image);
    // Compute the descriptor region size based in the input image size
    int featureRadius = config.featureRadius.computeI(Math.max(width, height));
    // Extract feature and track information from the current frame
    currentFrame.reserve(activeTracks.size());
    for (int i = 0; i < activeTracks.size(); i++) {
        PointTrack t = activeTracks.get(i);
        currentFrame.trackID_to_index.put(t.featureId, i);
        currentFrame.locations.grow().setTo(t.pixel);
        descriptor.process(t.pixel.x, t.pixel.y, 0.0, featureRadius, currentFrame.descriptions.grow());
    }
    if (verbose != null)
        verbose.printf("current_frame: tracks=%4d frame=%d\n", activeTracks.size(), frameNumber);
}
Also used : PointTrack(boofcv.abst.tracker.PointTrack)

Example 32 with PointTrack

use of boofcv.abst.tracker.PointTrack 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
    }
}
Also used : Frame(boofcv.alg.similar.SimilarImagesFromTracks.Frame) PointTrack(boofcv.abst.tracker.PointTrack) Match(boofcv.alg.similar.SimilarImagesFromTracks.Match) Test(org.junit.jupiter.api.Test)

Example 33 with PointTrack

use of boofcv.abst.tracker.PointTrack 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;
}
Also used : PointTrack(boofcv.abst.tracker.PointTrack) Frame(boofcv.alg.similar.SimilarImagesFromTracks.Frame) Match(boofcv.alg.similar.SimilarImagesFromTracks.Match)

Example 34 with PointTrack

use of boofcv.abst.tracker.PointTrack in project BoofCV by lessthanoptimal.

the class PointTrackerPerfectCloud method spawnTracks.

@Override
public void spawnTracks() {
    spawnable.forEach(spawn -> {
        long id = totalTracks++;
        cloudIdx_to_id.put(spawn.cloudIdx, id);
        PointTrack track = activeTracks.grow();
        track.featureId = id;
        track.detectorSetId = 0;
        track.spawnFrameID = frameID;
        track.lastSeenFrameID = frameID;
        track.pixel.setTo(spawn.pixel);
        id_to_track.put(id, track);
        spawned.add(track);
    });
}
Also used : PointTrack(boofcv.abst.tracker.PointTrack)

Example 35 with PointTrack

use of boofcv.abst.tracker.PointTrack in project BoofCV by lessthanoptimal.

the class TestPointTrackerPerfectCloud method basics.

/**
 * Test basic functionality
 */
@Test
void basics() {
    var tracker = new PointTrackerPerfectCloud<>();
    tracker.setCamera(new CameraPinhole(200, 200, 0, 200, 200, 400, 400));
    tracker.cloud.add(new Point3D_F64(0.0, 0.0, 2));
    tracker.cloud.add(new Point3D_F64(0.5, 0.0, 3));
    tracker.cloud.add(new Point3D_F64(0.0, 0.5, -2));
    // There is no max spawn
    assertEquals(0, tracker.getMaxSpawn());
    tracker.process(null);
    assertEquals(0, tracker.getFrameID());
    assertEquals(0, tracker.getTotalActive());
    // Only two tracks should be created since the 3rd is behind
    tracker.spawnTracks();
    assertEquals(2, tracker.getTotalActive());
    // sanity check the pixel coordinates
    List<PointTrack> active = tracker.getActiveTracks(null);
    assertEquals(2, active.size());
    assertEquals(200, active.get(0).pixel.x, UtilEjml.TEST_F64);
    assertEquals(200, active.get(0).pixel.y, UtilEjml.TEST_F64);
    assertTrue(active.get(1).pixel.x > 0);
    assertEquals(200, active.get(1).pixel.y, UtilEjml.TEST_F64);
    // See what happens when we flip it around and it can only see the 3rd point
    ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0, Math.PI, 0, tracker.world_to_view.R);
    tracker.process(null);
    // it should drop the two active tracks
    assertEquals(0, tracker.getTotalActive());
    assertEquals(2, tracker.getDroppedTracks(null).size());
    // it should just spawn the point with a negative coordinate
    tracker.spawnTracks();
    assertEquals(1, tracker.getTotalActive());
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) PointTrack(boofcv.abst.tracker.PointTrack) CameraPinhole(boofcv.struct.calib.CameraPinhole) Test(org.junit.jupiter.api.Test)

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