use of boofcv.abst.feature.tracker.PointTrack in project BoofCV by lessthanoptimal.
the class VisOdomDualTrackPnP method estimateMotion.
/**
* Given the set of active tracks, estimate the cameras motion robustly
* @return
*/
private boolean estimateMotion() {
// organize the data
List<Stereo2D3D> data = new ArrayList<>();
for (PointTrack l : candidates) {
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);
}
// Robustly estimate left camera motion
if (!matcher.process(data))
return false;
Se3_F64 keyToCurr = matcher.getModelParameters();
keyToCurr.invert(currToKey);
// mark tracks that are in the inlier set
int N = matcher.getMatchSet().size();
for (int i = 0; i < N; i++) {
int index = matcher.getInputIndex(i);
LeftTrackInfo info = candidates.get(index).getCookie();
info.lastInlier = tick;
}
return true;
}
use of boofcv.abst.feature.tracker.PointTrack in project BoofCV by lessthanoptimal.
the class VisOdomMonoPlaneInfinity method changeCurrToReference.
/**
* 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 changeCurrToReference() {
Se2_F64 keyToCurr = currToKey.invert(null);
List<PointTrack> all = tracker.getAllTracks(null);
for (PointTrack t : all) {
VoTrack p = t.getCookie();
if (p.onPlane) {
SePointOps_F64.transform(keyToCurr, p.ground, p.ground);
} else {
GeometryMath_F64.rotate(keyToCurr.c, keyToCurr.s, p.ground, p.ground);
}
}
concatMotion();
}
use of boofcv.abst.feature.tracker.PointTrack in project BoofCV by lessthanoptimal.
the class VisOdomPixelDepthPnP method performSecondPass.
private boolean performSecondPass(List<PointTrack> active, List<Point2D3D> obs) {
Se3_F64 keyToCurr = motionEstimator.getModelParameters();
Point3D_F64 cameraPt = new Point3D_F64();
Point2D_F64 predicted = new Point2D_F64();
// predict where each track should be given the just estimated motion
List<PointTrack> all = tracker.getAllTracks(null);
for (PointTrack t : all) {
Point2D3D p = t.getCookie();
SePointOps_F64.transform(keyToCurr, p.location, cameraPt);
normToPixel.compute(cameraPt.x / cameraPt.z, cameraPt.y / cameraPt.z, predicted);
tracker.setHint(predicted.x, predicted.y, t);
}
// redo tracking with the additional information
tracker.performSecondPass();
active.clear();
obs.clear();
tracker.getActiveTracks(active);
for (PointTrack t : active) {
Point2D3D p = t.getCookie();
pixelToNorm.compute(t.x, t.y, p.observation);
obs.add(p);
}
return motionEstimator.process(obs);
}
use of boofcv.abst.feature.tracker.PointTrack in project BoofCV by lessthanoptimal.
the class VisOdomPixelDepthPnP 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 = tracker.getAllTracks(null);
for (PointTrack t : all) {
Point2D3DTrack p = t.getCookie();
SePointOps_F64.transform(keyToCurr, p.location, p.location);
}
concatMotion();
}
use of boofcv.abst.feature.tracker.PointTrack in project BoofCV by lessthanoptimal.
the class ExamplePointFeatureTracker method updateGUI.
/**
* Draw tracked features in blue, or red if they were just spawned.
*/
private void updateGUI(SimpleImageSequence<T> sequence) {
BufferedImage orig = sequence.getGuiImage();
Graphics2D g2 = orig.createGraphics();
// draw tracks with semi-unique colors so you can track individual points with your eyes
for (PointTrack p : tracker.getActiveTracks(null)) {
int red = (int) (2.5 * (p.featureId % 100));
int green = (int) ((255.0 / 150.0) * (p.featureId % 150));
int blue = (int) (p.featureId % 255);
VisualizeFeatures.drawPoint(g2, (int) p.x, (int) p.y, new Color(red, green, blue));
}
// draw tracks which have just been spawned green
for (PointTrack p : tracker.getNewTracks(null)) {
VisualizeFeatures.drawPoint(g2, (int) p.x, (int) p.y, Color.green);
}
// tell the GUI to update
gui.setImage(orig);
gui.repaint();
}
Aggregations