Search in sources :

Example 91 with DogArray_I32

use of org.ddogleg.struct.DogArray_I32 in project BoofCV by lessthanoptimal.

the class DetectDescribeAssociateTracker method process.

/**
 * Detect features and associate with existing tracks
 */
public void process(I input) {
    if (frameID == -1)
        associate.initializeAssociator(input.width, input.height);
    frameID++;
    tracksActive.clear();
    tracksInactive.clear();
    tracksDropped.clear();
    tracksNew.clear();
    detector.detect(input);
    final int N = detector.getNumberOfFeatures();
    // initialize data structures
    dstDesc.resize(N);
    dstSet.resize(N);
    dstPixels.resize(N);
    // create a list of detected feature descriptions
    for (int i = 0; i < N; i++) {
        dstDesc.data[i] = detector.getDescription(i);
        dstSet.data[i] = detector.getSet(i);
        dstPixels.data[i] = detector.getLocation(i);
    }
    if (tracksAll.size == 0) {
        return;
    }
    performTracking();
    // add unassociated to the list
    DogArray_I32 unassociatedIdx = associate.getUnassociatedSource();
    for (int j = 0; j < unassociatedIdx.size(); j++) {
        tracksInactive.add(tracksAll.get(unassociatedIdx.get(j)));
    }
    dropExcessiveInactiveTracks(unassociatedIdx);
}
Also used : DogArray_I32(org.ddogleg.struct.DogArray_I32) DetectDescribePoint(boofcv.abst.feature.detdesc.DetectDescribePoint)

Example 92 with DogArray_I32

use of org.ddogleg.struct.DogArray_I32 in project BoofCV by lessthanoptimal.

the class HybridTrackerScalePoint method spawnNewTracks.

/**
 * Spawns new tracks from the list of unassociated detections. Must call {@link #associateInactiveTracks} first.
 */
public void spawnNewTracks() {
    // mark detected features with no matches as available
    DogArray_I32 unassociatedDetected = associate.getUnassociatedDestination();
    // spawn new tracks for unassociated detected features
    for (int unassociatedIdx = 0; unassociatedIdx < unassociatedDetected.size; unassociatedIdx++) {
        int detectedIdx = unassociatedDetected.get(unassociatedIdx);
        Point2D_F64 p = detectedPixels.data[detectedIdx];
        HybridTrack<TD> track = tracksAll.grow();
        // KLT track descriptor shape isn't known until after the first image has been processed
        if (track.trackKlt == null)
            track.trackKlt = trackerKlt.createNewTrack();
        // create the descriptor for KLT tracking
        trackerKlt.setDescription((float) p.x, (float) p.y, track.trackKlt);
        // set track ID and location
        track.respawned = false;
        track.spawnFrameID = track.lastSeenFrameID = frameID;
        track.featureId = totalTracks++;
        track.descriptor.setTo(detectedDesc.get(detectedIdx));
        track.detectorSetId = detectedSet.get(detectedIdx);
        track.pixel.setTo(p);
        // update list of active tracks
        tracksActive.add(track);
        tracksSpawned.add(track);
    }
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) DogArray_I32(org.ddogleg.struct.DogArray_I32) DetectDescribePoint(boofcv.abst.feature.detdesc.DetectDescribePoint)

Example 93 with DogArray_I32

use of org.ddogleg.struct.DogArray_I32 in project BoofCV by lessthanoptimal.

the class SplitMergeLineFitSegment method splitSegments.

/**
 * Splits a line in two if there is a paint that is too far away
 *
 * @return true for change
 */
protected boolean splitSegments() {
    boolean change = false;
    work.reset();
    for (int i = 0; i < splits.size - 1; i++) {
        int start = splits.data[i];
        int end = splits.data[i + 1];
        int bestIndex = selectSplitBetween(start, end);
        if (bestIndex >= 0) {
            change |= true;
            work.add(start);
            work.add(bestIndex);
        } else {
            work.add(start);
        }
    }
    work.add(splits.data[splits.size - 1]);
    // swap the two lists
    DogArray_I32 tmp = work;
    work = splits;
    splits = tmp;
    return change;
}
Also used : DogArray_I32(org.ddogleg.struct.DogArray_I32)

Example 94 with DogArray_I32

use of org.ddogleg.struct.DogArray_I32 in project BoofCV by lessthanoptimal.

the class ChecksGenericPointsToPolyline method checkMinVertexes_loop.

/**
 * Checks to see if this feature can be changed and is enforced
 */
@Test
void checkMinVertexes_loop() {
    PointsToPolyline alg = createAlg(true);
    alg.setConvex(false);
    alg.setMinimumSides(10);
    List<Point2D_I32> contour = line(0, 0, 30, 0);
    contour.addAll(line(30, 0, 30, 10));
    contour.addAll(line(30, 10, 20, 10));
    contour.addAll(line(20, 10, 20, 30));
    contour.addAll(line(20, 30, 0, 30));
    contour.addAll(line(0, 30, 0, 0));
    DogArray_I32 found = new DogArray_I32();
    if (alg.process(contour, found)) {
        assertEquals(10, found.size);
    }
    alg.setMinimumSides(3);
    assertTrue(alg.process(contour, found));
    check(found, 0, 30, 40, 50, 70, 90);
}
Also used : Point2D_I32(georegression.struct.point.Point2D_I32) DogArray_I32(org.ddogleg.struct.DogArray_I32) Test(org.junit.jupiter.api.Test)

Example 95 with DogArray_I32

use of org.ddogleg.struct.DogArray_I32 in project BoofCV by lessthanoptimal.

the class ChecksGenericPointsToPolyline method checkMaxVertexes_loop.

/**
 * Checks to see if this feature can be changed and is enforced
 */
@Test
void checkMaxVertexes_loop() {
    PointsToPolyline alg = createAlg(true);
    alg.setMaximumSides(3);
    List<Point2D_I32> contour = TestPolylineSplitMerge.rect(0, 0, 10, 20);
    DogArray_I32 found = new DogArray_I32();
    // will fail because the error is too large for 3 sides
    assertFalse(alg.process(contour, found));
    alg.setMaximumSides(4);
    assertTrue(alg.process(contour, found));
    check(found, 0, 10, 30, 40);
}
Also used : Point2D_I32(georegression.struct.point.Point2D_I32) DogArray_I32(org.ddogleg.struct.DogArray_I32) Test(org.junit.jupiter.api.Test)

Aggregations

DogArray_I32 (org.ddogleg.struct.DogArray_I32)192 Test (org.junit.jupiter.api.Test)73 Point2D_I32 (georegression.struct.point.Point2D_I32)24 ArrayList (java.util.ArrayList)21 Point2D_F64 (georegression.struct.point.Point2D_F64)17 DogArray (org.ddogleg.struct.DogArray)17 TupleDesc_F64 (boofcv.struct.feature.TupleDesc_F64)15 GrayS32 (boofcv.struct.image.GrayS32)10 VerbosePrint (org.ddogleg.struct.VerbosePrint)7 View (boofcv.alg.structure.PairwiseImageGraph.View)6 AssociatedIndex (boofcv.struct.feature.AssociatedIndex)6 GrayI (boofcv.struct.image.GrayI)5 Point3D_F64 (georegression.struct.point.Point3D_F64)5 GrowArray (pabeles.concurrency.GrowArray)5 DetectDescribePoint (boofcv.abst.feature.detdesc.DetectDescribePoint)4 BTrack (boofcv.alg.sfm.d3.structure.VisOdomBundleAdjustment.BTrack)4 AssociatedTripleIndex (boofcv.struct.feature.AssociatedTripleIndex)4 SceneObservations (boofcv.abst.geo.bundle.SceneObservations)3 SceneWorkingGraph (boofcv.alg.structure.SceneWorkingGraph)3 ConfigAssociateGreedy (boofcv.factory.feature.associate.ConfigAssociateGreedy)3