Search in sources :

Example 21 with Se3_F64

use of georegression.struct.se.Se3_F64 in project BoofCV by lessthanoptimal.

the class TestCalibPoseAndPointRodiguesCodec method checkZeroAngle.

/**
 * A pathological situation for Rodigues coordinates is zero degrees
 */
@Test
public void checkZeroAngle() {
    int numViews = 1;
    int numPoints = 0;
    // Set a world transform of zero degrees
    CalibratedPoseAndPoint model = new CalibratedPoseAndPoint();
    model.configure(numViews, numPoints);
    model.getWorldToCamera(0).getT().set(1, 2, 3);
    // encode the model
    CalibPoseAndPointRodriguesCodec codec = new CalibPoseAndPointRodriguesCodec();
    codec.configure(numViews, numPoints, numViews, new boolean[] { false });
    double[] param = new double[codec.getParamLength()];
    codec.encode(model, param);
    // decode the model
    CalibratedPoseAndPoint found = new CalibratedPoseAndPoint();
    found.configure(numViews, numPoints);
    codec.decode(param, found);
    // compare results
    for (int i = 0; i < numViews; i++) {
        Se3_F64 o = model.getWorldToCamera(i);
        Se3_F64 f = found.getWorldToCamera(i);
        assertEquals(0, o.getT().distance(f.getT()), 1e-8);
        assertTrue(MatrixFeatures_DDRM.isIdentical(o.getR(), f.getR(), 1e-8));
    }
}
Also used : Se3_F64(georegression.struct.se.Se3_F64) Test(org.junit.Test)

Example 22 with Se3_F64

use of georegression.struct.se.Se3_F64 in project BoofCV by lessthanoptimal.

the class TestPnPRefineRodrigues method noisy.

@Test
public void noisy() {
    Se3_F64 motion = new Se3_F64();
    motion.getR().set(ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.05, -0.03, 0.02, null));
    motion.getT().set(0.1, -0.1, 0.01);
    generateScene(50, motion, false);
    PnPRefineRodrigues alg = new PnPRefineRodrigues(1e-20, 500);
    Se3_F64 n = motion.copy();
    n.getT().setX(0);
    assertTrue(alg.fitModel(pointPose, n, found));
    assertEquals(motion.getT().getX(), found.getX(), 1e-5);
    assertEquals(motion.getT().getY(), found.getY(), 1e-5);
    assertEquals(motion.getT().getZ(), found.getZ(), 1e-5);
}
Also used : Se3_F64(georegression.struct.se.Se3_F64) Test(org.junit.Test)

Example 23 with Se3_F64

use of georegression.struct.se.Se3_F64 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);
    }
}
Also used : PointTrack(boofcv.abst.feature.tracker.PointTrack) Stereo2D3D(boofcv.struct.sfm.Stereo2D3D) ArrayList(java.util.ArrayList) DescribeRegionPoint(boofcv.abst.feature.describe.DescribeRegionPoint) Se3_F64(georegression.struct.se.Se3_F64)

Example 24 with Se3_F64

use of georegression.struct.se.Se3_F64 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();
}
Also used : PointTrack(boofcv.abst.feature.tracker.PointTrack) Se3_F64(georegression.struct.se.Se3_F64)

Example 25 with Se3_F64

use of georegression.struct.se.Se3_F64 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;
}
Also used : PointTrack(boofcv.abst.feature.tracker.PointTrack) Stereo2D3D(boofcv.struct.sfm.Stereo2D3D) ArrayList(java.util.ArrayList) DescribeRegionPoint(boofcv.abst.feature.describe.DescribeRegionPoint) Se3_F64(georegression.struct.se.Se3_F64)

Aggregations

Se3_F64 (georegression.struct.se.Se3_F64)214 Test (org.junit.Test)83 Point3D_F64 (georegression.struct.point.Point3D_F64)74 Point2D_F64 (georegression.struct.point.Point2D_F64)68 DMatrixRMaj (org.ejml.data.DMatrixRMaj)52 Point2D3D (boofcv.struct.geo.Point2D3D)31 Vector3D_F64 (georegression.struct.point.Vector3D_F64)30 ArrayList (java.util.ArrayList)27 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)26 GrayF32 (boofcv.struct.image.GrayF32)18 AssociatedPair (boofcv.struct.geo.AssociatedPair)17 StereoParameters (boofcv.struct.calib.StereoParameters)12 GrayU8 (boofcv.struct.image.GrayU8)10 BufferedImage (java.awt.image.BufferedImage)10 PointTrack (boofcv.abst.feature.tracker.PointTrack)9 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)9 Stereo2D3D (boofcv.struct.sfm.Stereo2D3D)9 ModelManagerSe3_F64 (georegression.fitting.se.ModelManagerSe3_F64)9 RectifyCalibrated (boofcv.alg.geo.rectify.RectifyCalibrated)8 LensDistortionNarrowFOV (boofcv.alg.distort.LensDistortionNarrowFOV)7