use of boofcv.abst.feature.tracker.PointTrack in project BoofCV by lessthanoptimal.
the class ImageMotionPtkSmartRespawn method pruneClosePoints.
private void pruneClosePoints(PointTracker<I> tracker, int width, int height) {
pruneClose.resize(width, height);
// prune some of the ones which are too close
prune.clear();
pruneClose.process(tracker.getActiveTracks(null), prune);
for (PointTrack t : prune) {
tracker.dropTrack(t);
}
}
use of boofcv.abst.feature.tracker.PointTrack in project BoofCV by lessthanoptimal.
the class PruneCloseTracks method process.
public void process(List<PointTrack> tracks, List<PointTrack> dropTracks) {
int w = imgWidth / scale;
int h = imgHeight / scale;
int l = w * h;
for (int i = 0; i < l; i++) pairImage[i] = null;
for (int i = 0; i < tracks.size(); i++) {
PointTrack p = tracks.get(i);
int x = (int) (p.x / scale);
int y = (int) (p.y / scale);
int index = y * w + x;
if (pairImage[index] == null) {
pairImage[index] = p;
} else {
dropTracks.add(p);
}
}
}
use of boofcv.abst.feature.tracker.PointTrack in project BoofCV by lessthanoptimal.
the class VisOdomDualTrackPnP method refineMotionEstimate.
/**
* Non-linear refinement of motion estimate
*/
private void refineMotionEstimate() {
// use observations from the inlier set
List<Stereo2D3D> data = new ArrayList<>();
int N = matcher.getMatchSet().size();
for (int i = 0; i < N; i++) {
int index = matcher.getInputIndex(i);
PointTrack l = candidates.get(index);
LeftTrackInfo info = l.getCookie();
PointTrack r = info.right;
Stereo2D3D stereo = info.location;
// compute normalized image coordinate for track in left and right image
leftImageToNorm.compute(l.x, l.y, info.location.leftObs);
rightImageToNorm.compute(r.x, r.y, info.location.rightObs);
data.add(stereo);
}
// refine the motion estimate using non-linear optimization
Se3_F64 keyToCurr = currToKey.invert(null);
Se3_F64 found = new Se3_F64();
if (modelRefiner.fitModel(data, keyToCurr, found)) {
found.invert(currToKey);
}
}
use of boofcv.abst.feature.tracker.PointTrack in project BoofCV by lessthanoptimal.
the class VisOdomDualTrackPnP method dropUnusedTracks.
/**
* Removes tracks which have not been included in the inlier set recently
*
* @return Number of dropped tracks
*/
private int dropUnusedTracks() {
List<PointTrack> all = trackerLeft.getAllTracks(null);
int num = 0;
for (PointTrack t : all) {
LeftTrackInfo info = t.getCookie();
if (tick - info.lastInlier > thresholdRetire) {
if (!trackerLeft.dropTrack(t))
throw new IllegalArgumentException("failed to drop unused left track");
if (!trackerRight.dropTrack(info.right))
throw new IllegalArgumentException("failed to drop unused right track");
num++;
}
}
return num;
}
use of boofcv.abst.feature.tracker.PointTrack in project BoofCV by lessthanoptimal.
the class VisOdomDualTrackPnP method changePoseToReference.
/**
* Updates the relative position of all points so that the current frame is the reference frame. Mathematically
* this is not needed, but should help keep numbers from getting too large.
*/
private void changePoseToReference() {
Se3_F64 keyToCurr = currToKey.invert(null);
List<PointTrack> all = trackerLeft.getAllTracks(null);
for (PointTrack t : all) {
LeftTrackInfo p = t.getCookie();
SePointOps_F64.transform(keyToCurr, p.location.location, p.location.location);
}
concatMotion();
}
Aggregations