Search in sources :

Example 86 with Se3_F64

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

the class FactoryMultiViewRobust method epipolarRansac.

private static Ransac<Se3_F64, AssociatedPair> epipolarRansac(Estimate1ofEpipolar epipolar, CameraPinholeRadial intrinsic, ConfigRansac ransac) {
    TriangulateTwoViewsCalibrated triangulate = FactoryMultiView.triangulateTwoGeometric();
    ModelManager<Se3_F64> manager = new ModelManagerSe3_F64();
    ModelGenerator<Se3_F64, AssociatedPair> generateEpipolarMotion = new Se3FromEssentialGenerator(epipolar, triangulate);
    DistanceFromModel<Se3_F64, AssociatedPair> distanceSe3 = new DistanceSe3SymmetricSq(triangulate, intrinsic.fx, intrinsic.fy, intrinsic.skew, intrinsic.fx, intrinsic.fy, intrinsic.skew);
    double ransacTOL = ransac.inlierThreshold * ransac.inlierThreshold * 2.0;
    return new Ransac<>(ransac.randSeed, manager, generateEpipolarMotion, distanceSe3, ransac.maxIterations, ransacTOL);
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) DistanceSe3SymmetricSq(boofcv.alg.geo.robust.DistanceSe3SymmetricSq) ModelManagerSe3_F64(georegression.fitting.se.ModelManagerSe3_F64) Se3FromEssentialGenerator(boofcv.alg.geo.robust.Se3FromEssentialGenerator) Ransac(org.ddogleg.fitting.modelset.ransac.Ransac) TriangulateTwoViewsCalibrated(boofcv.abst.geo.TriangulateTwoViewsCalibrated) Se3_F64(georegression.struct.se.Se3_F64) ModelManagerSe3_F64(georegression.fitting.se.ModelManagerSe3_F64)

Example 87 with Se3_F64

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

the class FactoryMultiView method computePnP_1.

/**
 * Created an estimator for the P3P problem that selects a single solution by considering additional
 * observations.
 *
 * <p>NOTE: Observations are in normalized image coordinates NOT pixels.</p>
 *
 * <p>
 * NOTE: EPnP has several tuning parameters and the defaults here might not be the best for your situation.
 * Use {@link #computePnPwithEPnP} if you wish to have access to all parameters.
 * </p>
 *
 * @param which The algorithm which is to be returned.
 * @param numIterations Number of iterations. Only used by some algorithms and recommended number varies
 *                      significantly by algorithm.
 * @param numTest How many additional sample points are used to remove ambiguity in the solutions.  Not used
 *                if only a single solution is found.
 * @return An estimator which returns a single estimate.
 */
public static Estimate1ofPnP computePnP_1(EnumPNP which, int numIterations, int numTest) {
    if (which == EnumPNP.EPNP) {
        PnPLepetitEPnP alg = new PnPLepetitEPnP(0.1);
        alg.setNumIterations(numIterations);
        return new WrapPnPLepetitEPnP(alg);
    }
    FastQueue<Se3_F64> solutions = new FastQueue<>(4, Se3_F64.class, true);
    return new EstimateNto1ofPnP(computePnP_N(which, -1), solutions, numTest);
}
Also used : PnPLepetitEPnP(boofcv.alg.geo.pose.PnPLepetitEPnP) FastQueue(org.ddogleg.struct.FastQueue) Se3_F64(georegression.struct.se.Se3_F64)

Example 88 with Se3_F64

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

the class TestAssociateStereo2D method setup.

@Before
public void setup() {
    leftToRight = new Se3_F64();
    ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.01, -0.001, 0.005, leftToRight.getR());
    leftToRight.getT().set(-0.1, 0, 0);
    param = new StereoParameters();
    param.rightToLeft = leftToRight.invert(null);
    param.left = new CameraPinholeRadial(400, 500, 0.1, 160, 120, 320, 240).fsetRadial(0, 0);
    param.right = new CameraPinholeRadial(380, 505, 0.05, 165, 115, 320, 240).fsetRadial(0, 0);
    descLeft = new FastQueue<TupleDesc_F64>(TupleDesc_F64.class, true) {

        @Override
        protected TupleDesc_F64 createInstance() {
            return new TupleDesc_F64(10);
        }
    };
    descRight = new FastQueue<TupleDesc_F64>(TupleDesc_F64.class, true) {

        @Override
        protected TupleDesc_F64 createInstance() {
            return new TupleDesc_F64(10);
        }
    };
    pointsLeft.reset();
    pointsRight.reset();
}
Also used : TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) StereoParameters(boofcv.struct.calib.StereoParameters) Se3_F64(georegression.struct.se.Se3_F64) Before(org.junit.Before)

Example 89 with Se3_F64

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

the class TestStereoConsistencyCheck method checkRectification.

@Test
public void checkRectification() {
    Se3_F64 leftToRight = new Se3_F64();
    ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.01, -0.001, 0.005, leftToRight.getR());
    leftToRight.getT().set(-0.1, 0, 0);
    StereoParameters param = new StereoParameters();
    param.rightToLeft = leftToRight.invert(null);
    param.left = new CameraPinholeRadial(400, 500, 0.1, 160, 120, 320, 240).fsetRadial(0, 0);
    param.right = new CameraPinholeRadial(380, 505, 0.05, 165, 115, 320, 240).fsetRadial(0, 0);
    Point3D_F64 X = new Point3D_F64(0.02, -0.5, 3);
    Point2D_F64 leftP = new Point2D_F64();
    Point2D_F64 rightP = new Point2D_F64();
    SfmTestHelper.renderPointPixel(param, X, leftP, rightP);
    StereoConsistencyCheck alg = new StereoConsistencyCheck(1, 2);
    alg.setCalibration(param);
    alg.checkPixel(leftP, rightP);
    assertEquals(alg.rectLeft.y, alg.rectRight.y, 1e-5);
    assertTrue(alg.rectLeft.x > alg.rectRight.x);
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) Point2D_F64(georegression.struct.point.Point2D_F64) StereoParameters(boofcv.struct.calib.StereoParameters) Se3_F64(georegression.struct.se.Se3_F64) Test(org.junit.Test)

Example 90 with Se3_F64

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

the class CommonStereoMotionNPoint method generateScene.

protected void generateScene(int N, Se3_F64 worldToLeft, boolean planar) {
    if (worldToLeft == null) {
        this.worldToLeft = worldToLeft = new Se3_F64();
        ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.1, 1, -0.2, worldToLeft.getR());
        worldToLeft.getT().set(-0.3, 0.4, 1);
    } else {
        this.worldToLeft = worldToLeft;
    }
    // randomly generate points in space
    if (planar) {
        worldPts = createRandomPlane(rand, 3, N);
    } else {
        worldPts = GeoTestingOps.randomPoints_F64(-1, 1, -1, 1, 2, 3, N, rand);
    }
    cameraLeftPts = new ArrayList<>();
    cameraRightPts = new ArrayList<>();
    // transform points into second camera's reference frame
    pointPose = new ArrayList<>();
    for (Point3D_F64 p1 : worldPts) {
        Point3D_F64 leftPt = SePointOps_F64.transform(worldToLeft, p1, null);
        Point3D_F64 rightPt = SePointOps_F64.transform(leftToRight, leftPt, null);
        Point2D_F64 leftObs = new Point2D_F64(leftPt.x / leftPt.z, leftPt.y / leftPt.z);
        Point2D_F64 rightObs = new Point2D_F64(rightPt.x / rightPt.z, rightPt.y / rightPt.z);
        pointPose.add(new Stereo2D3D(leftObs, rightObs, p1));
        cameraLeftPts.add(leftPt);
        cameraRightPts.add(rightPt);
    }
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) Point2D_F64(georegression.struct.point.Point2D_F64) Stereo2D3D(boofcv.struct.sfm.Stereo2D3D) 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