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);
}
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);
}
}
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;
}
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);
}
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);
}
Aggregations