Search in sources :

Example 16 with LensDistortionPinhole

use of boofcv.alg.distort.pinhole.LensDistortionPinhole in project BoofCV by lessthanoptimal.

the class TestVisOdomBundleAdjustment method createPerfectScene.

private void createPerfectScene(VisOdomBundleAdjustment<BTrack> vsba) {
    vsba.reset();
    List<Point3D_F64> cloud = UtilPoint3D_F64.random(new Point3D_F64(0, 0, 1.5), -1.5, 1.5, -0.5, 0.5, -0.2, 0.2, 500, rand);
    LensDistortionPinhole distortion = new LensDistortionPinhole(pinhole);
    Point2Transform2_F64 n2n = distortion.distort_F64(false, false);
    vsba.addCamera(pinhole);
    // 3D point in view reference frame
    Point3D_F64 Xv = new Point3D_F64();
    // normalized image coordinate
    Point2D_F64 n = new Point2D_F64();
    // pixel coordinate
    Point2D_F64 p = new Point2D_F64();
    for (int i = 0; i < cloud.size(); i++) {
        Point3D_F64 X = cloud.get(i);
        vsba.addTrack(X.x, X.y, X.z, 1.0).hasBeenInlier = true;
    }
    for (int viewidx = 0; viewidx < 5; viewidx++) {
        BFrame frame = vsba.addFrame(viewidx);
        frame.frame_to_world.setTo(-1 + 2.0 * viewidx / 4.0, 0, 0, EulerType.XYZ, rand.nextGaussian() * 0.1, 0, 0);
        // add visible features to each view
        for (int i = 0; i < cloud.size(); i++) {
            Point3D_F64 X = cloud.get(i);
            frame.frame_to_world.transformReverse(X, Xv);
            if (Xv.z <= 0)
                continue;
            n2n.compute(Xv.x / Xv.z, Xv.y / Xv.z, n);
            PerspectiveOps.convertNormToPixel(pinhole, n.x, n.y, p);
            if (!pinhole.isInside(p.x, p.y))
                continue;
            BTrack track = vsba.tracks.get(i);
            vsba.addObservation(frame, track, p.x, p.y);
        }
    }
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) UtilPoint3D_F64(georegression.geometry.UtilPoint3D_F64) LensDistortionPinhole(boofcv.alg.distort.pinhole.LensDistortionPinhole) BFrame(boofcv.alg.sfm.d3.structure.VisOdomBundleAdjustment.BFrame) Point2D_F64(georegression.struct.point.Point2D_F64) Point2Transform2_F64(boofcv.struct.distort.Point2Transform2_F64) BTrack(boofcv.alg.sfm.d3.structure.VisOdomBundleAdjustment.BTrack)

Example 17 with LensDistortionPinhole

use of boofcv.alg.distort.pinhole.LensDistortionPinhole in project BoofCV by lessthanoptimal.

the class TestResolveSceneScaleAmbiguity method createPixelToNorm.

private List<Point2Transform2_F64> createPixelToNorm(int... viewIndexes) {
    var ret = new ArrayList<Point2Transform2_F64>();
    for (int viewIdx : viewIndexes) {
        var pixel_to_norm = new LensDistortionPinhole(listCameras.get(viewIdx)).distort_F64(true, false);
        ret.add(pixel_to_norm);
    }
    return ret;
}
Also used : LensDistortionPinhole(boofcv.alg.distort.pinhole.LensDistortionPinhole) ArrayList(java.util.ArrayList)

Aggregations

LensDistortionPinhole (boofcv.alg.distort.pinhole.LensDistortionPinhole)17 CameraPinhole (boofcv.struct.calib.CameraPinhole)7 Test (org.junit.jupiter.api.Test)6 LensDistortionNarrowFOV (boofcv.alg.distort.LensDistortionNarrowFOV)4 Point2Transform2_F64 (boofcv.struct.distort.Point2Transform2_F64)4 GrayU8 (boofcv.struct.image.GrayU8)4 LensDistortionUniversalOmni (boofcv.alg.distort.universal.LensDistortionUniversalOmni)3 PointToPixelTransform_F32 (boofcv.struct.distort.PointToPixelTransform_F32)3 GrayF32 (boofcv.struct.image.GrayF32)3 Planar (boofcv.struct.image.Planar)3 UtilPoint3D_F64 (georegression.geometry.UtilPoint3D_F64)3 Point3D_F64 (georegression.struct.point.Point3D_F64)3 NarrowToWidePtoP_F32 (boofcv.alg.distort.NarrowToWidePtoP_F32)2 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)2 CameraUniversalOmni (boofcv.struct.calib.CameraUniversalOmni)2 Point2D_F64 (georegression.struct.point.Point2D_F64)2 Se3_F64 (georegression.struct.se.Se3_F64)2 BufferedImage (java.awt.image.BufferedImage)2 File (java.io.File)2 LensDistortionWideFOV (boofcv.alg.distort.LensDistortionWideFOV)1