use of georegression.struct.se.Se3_F64 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 georegression.struct.se.Se3_F64 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 georegression.struct.se.Se3_F64 in project BoofCV by lessthanoptimal.
the class WrapVisOdomDualTrackPnP method setCalibration.
@Override
public void setCalibration(StereoParameters parameters) {
Se3_F64 leftToRight = parameters.getRightToLeft().invert(null);
pnp.setLeftToRight(leftToRight);
if (refine != null)
refine.setLeftToRight(leftToRight);
alg.setCalibration(parameters);
CameraPinholeRadial left = parameters.left;
distanceMono.setIntrinsic(left.fx, left.fy, left.skew);
distanceStereo.setStereoParameters(parameters);
assoc.setCalibration(parameters);
}
use of georegression.struct.se.Se3_F64 in project BoofCV by lessthanoptimal.
the class WrapVisOdomQuadPnP method setCalibration.
@Override
public void setCalibration(StereoParameters parameters) {
Se3_F64 leftToRight = parameters.getRightToLeft().invert(null);
alg.setCalibration(parameters);
associateStereo.setCalibration(parameters);
distance.setStereoParameters(parameters);
CameraPinholeRadial left = parameters.left;
distanceMono.setIntrinsic(left.fx, left.fy, left.skew);
if (refine != null)
refine.setLeftToRight(leftToRight);
}
use of georegression.struct.se.Se3_F64 in project BoofCV by lessthanoptimal.
the class FactoryVisualOdometry method stereoDepth.
/**
* Stereo vision based visual odometry algorithm which runs a sparse feature tracker in the left camera and
* estimates the range of tracks once when first detected using disparity between left and right cameras.
*
* @see VisOdomPixelDepthPnP
*
* @param thresholdAdd Add new tracks when less than this number are in the inlier set. Tracker dependent. Set to
* a value ≤ 0 to add features every frame.
* @param thresholdRetire Discard a track if it is not in the inlier set after this many updates. Try 2
* @param sparseDisparity Estimates the 3D location of features
* @param imageType Type of image being processed.
* @return StereoVisualOdometry
*/
public static <T extends ImageGray<T>> StereoVisualOdometry<T> stereoDepth(double inlierPixelTol, int thresholdAdd, int thresholdRetire, int ransacIterations, int refineIterations, boolean doublePass, StereoDisparitySparse<T> sparseDisparity, PointTrackerTwoPass<T> tracker, Class<T> imageType) {
// Range from sparse disparity
StereoSparse3D<T> pixelTo3D = new StereoSparse3D<>(sparseDisparity, imageType);
Estimate1ofPnP estimator = FactoryMultiView.computePnP_1(EnumPNP.P3P_FINSTERWALDER, -1, 2);
final DistanceModelMonoPixels<Se3_F64, Point2D3D> distance = new PnPDistanceReprojectionSq();
ModelManagerSe3_F64 manager = new ModelManagerSe3_F64();
EstimatorToGenerator<Se3_F64, Point2D3D> generator = new EstimatorToGenerator<>(estimator);
// 1/2 a pixel tolerance for RANSAC inliers
double ransacTOL = inlierPixelTol * inlierPixelTol;
ModelMatcher<Se3_F64, Point2D3D> motion = new Ransac<>(2323, manager, generator, distance, ransacIterations, ransacTOL);
RefinePnP refine = null;
if (refineIterations > 0) {
refine = FactoryMultiView.refinePnP(1e-12, refineIterations);
}
VisOdomPixelDepthPnP<T> alg = new VisOdomPixelDepthPnP<>(thresholdAdd, thresholdRetire, doublePass, motion, pixelTo3D, refine, tracker, null, null);
return new WrapVisOdomPixelDepthPnP<>(alg, pixelTo3D, distance, imageType);
}
Aggregations