Search in sources :

Example 16 with StereoParameters

use of boofcv.struct.calib.StereoParameters in project BoofCV by lessthanoptimal.

the class TestStereoVisualOdometryScaleInput method setCalibration.

@Test
public void setCalibration() {
    StereoParameters p = createStereoParam();
    Dummy dummy = new Dummy();
    StereoVisualOdometryScaleInput<GrayF32> alg = new StereoVisualOdometryScaleInput<>(dummy, 0.5);
    alg.setCalibration(p);
    assertEquals(320, parameters.left.width);
    assertEquals(320, parameters.right.width);
    assertEquals(160, parameters.left.height);
    assertEquals(160, parameters.right.height);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) StereoParameters(boofcv.struct.calib.StereoParameters) Test(org.junit.Test)

Example 17 with StereoParameters

use of boofcv.struct.calib.StereoParameters in project BoofCV by lessthanoptimal.

the class TestStereoVisualOdometryScaleInput method createStereoParam.

public StereoParameters createStereoParam() {
    StereoParameters ret = new StereoParameters();
    ret.setRightToLeft(new Se3_F64());
    ret.getRightToLeft().getT().set(-0.2, 0.001, -0.012);
    ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.001, -0.01, 0.0023, ret.getRightToLeft().getR());
    ret.left = new CameraPinholeRadial(200, 201, 0, width / 2, height / 2, width, height).fsetRadial(0, 0);
    ret.right = new CameraPinholeRadial(199, 200, 0, width / 2 + 2, height / 2 - 6, width, height).fsetRadial(0, 0);
    return ret;
}
Also used : CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) StereoParameters(boofcv.struct.calib.StereoParameters) Se3_F64(georegression.struct.se.Se3_F64)

Example 18 with StereoParameters

use of boofcv.struct.calib.StereoParameters in project BoofCV by lessthanoptimal.

the class VisualizeStereoDisparity method changeInputScale.

@Override
public synchronized void changeInputScale() {
    calib = new StereoParameters(origCalib);
    double scale = control.inputScale;
    PerspectiveOps.scaleIntrinsic(calib.left, scale);
    PerspectiveOps.scaleIntrinsic(calib.right, scale);
    int w = (int) (origLeft.getWidth() * scale);
    int h = (int) (origLeft.getHeight() * scale);
    colorLeft = new BufferedImage(w, h, BufferedImage.TYPE_INT_BGR);
    colorRight = new BufferedImage(w, h, BufferedImage.TYPE_INT_BGR);
    colorLeft.createGraphics().drawImage(origLeft, AffineTransform.getScaleInstance(scale, scale), null);
    colorRight.createGraphics().drawImage(origRight, AffineTransform.getScaleInstance(scale, scale), null);
    activeAlg = createAlg();
    inputLeft = GeneralizedImageOps.createSingleBand(activeAlg.getInputType(), w, h);
    inputRight = GeneralizedImageOps.createSingleBand(activeAlg.getInputType(), w, h);
    rectLeft = GeneralizedImageOps.createSingleBand(activeAlg.getInputType(), w, h);
    rectRight = GeneralizedImageOps.createSingleBand(activeAlg.getInputType(), w, h);
    ConvertBufferedImage.convertFrom(colorLeft, inputLeft, true);
    ConvertBufferedImage.convertFrom(colorRight, inputRight, true);
    rectifyInputImages();
    doRefreshAll();
}
Also used : StereoParameters(boofcv.struct.calib.StereoParameters) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage)

Example 19 with StereoParameters

use of boofcv.struct.calib.StereoParameters in project BoofCV by lessthanoptimal.

the class ShowRectifyCalibratedApp method changeInput.

@Override
public void changeInput(String name, int index) {
    PathLabel refs = inputRefs.get(index);
    StereoParameters param = CalibrationIO.load(media.openFile(refs.getPath(0)));
    BufferedImage origLeft = media.openImage(refs.getPath(1));
    BufferedImage origRight = media.openImage(refs.getPath(2));
    configure(origLeft, origRight, param);
}
Also used : PathLabel(boofcv.io.PathLabel) StereoParameters(boofcv.struct.calib.StereoParameters) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage)

Example 20 with StereoParameters

use of boofcv.struct.calib.StereoParameters in project BoofCV by lessthanoptimal.

the class ExampleVisualOdometryStereo method main.

public static void main(String[] args) {
    MediaManager media = DefaultMediaManager.INSTANCE;
    String directory = UtilIO.pathExample("vo/backyard/");
    // load camera description and the video sequence
    StereoParameters stereoParam = CalibrationIO.load(media.openFile(directory + "stereo.yaml"));
    SimpleImageSequence<GrayU8> video1 = media.openVideo(directory + "left.mjpeg", ImageType.single(GrayU8.class));
    SimpleImageSequence<GrayU8> video2 = media.openVideo(directory + "right.mjpeg", ImageType.single(GrayU8.class));
    // specify how the image features are going to be tracked
    PkltConfig configKlt = new PkltConfig();
    configKlt.pyramidScaling = new int[] { 1, 2, 4, 8 };
    configKlt.templateRadius = 3;
    PointTrackerTwoPass<GrayU8> tracker = FactoryPointTrackerTwoPass.klt(configKlt, new ConfigGeneralDetector(600, 3, 1), GrayU8.class, GrayS16.class);
    // computes the depth of each point
    StereoDisparitySparse<GrayU8> disparity = FactoryStereoDisparity.regionSparseWta(0, 150, 3, 3, 30, -1, true, GrayU8.class);
    // declares the algorithm
    StereoVisualOdometry<GrayU8> visualOdometry = FactoryVisualOdometry.stereoDepth(1.5, 120, 2, 200, 50, true, disparity, tracker, GrayU8.class);
    // Pass in intrinsic/extrinsic calibration.  This can be changed in the future.
    visualOdometry.setCalibration(stereoParam);
    // Process the video sequence and output the location plus number of inliers
    while (video1.hasNext()) {
        GrayU8 left = video1.next();
        GrayU8 right = video2.next();
        if (!visualOdometry.process(left, right)) {
            throw new RuntimeException("VO Failed!");
        }
        Se3_F64 leftToWorld = visualOdometry.getCameraToWorld();
        Vector3D_F64 T = leftToWorld.getT();
        System.out.printf("Location %8.2f %8.2f %8.2f      inliers %s\n", T.x, T.y, T.z, inlierPercent(visualOdometry));
    }
}
Also used : PkltConfig(boofcv.alg.tracker.klt.PkltConfig) ConfigGeneralDetector(boofcv.abst.feature.detect.interest.ConfigGeneralDetector) Vector3D_F64(georegression.struct.point.Vector3D_F64) MediaManager(boofcv.io.MediaManager) DefaultMediaManager(boofcv.io.wrapper.DefaultMediaManager) GrayU8(boofcv.struct.image.GrayU8) StereoParameters(boofcv.struct.calib.StereoParameters) Se3_F64(georegression.struct.se.Se3_F64)

Aggregations

StereoParameters (boofcv.struct.calib.StereoParameters)25 Se3_F64 (georegression.struct.se.Se3_F64)12 Test (org.junit.Test)9 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)8 BufferedImage (java.awt.image.BufferedImage)8 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)7 GrayF32 (boofcv.struct.image.GrayF32)7 GrayU8 (boofcv.struct.image.GrayU8)6 Point3D_F64 (georegression.struct.point.Point3D_F64)5 Point2D_F64 (georegression.struct.point.Point2D_F64)4 DMatrixRMaj (org.ejml.data.DMatrixRMaj)4 File (java.io.File)3 CalibrationObservation (boofcv.alg.geo.calibration.CalibrationObservation)2 RectifyCalibrated (boofcv.alg.geo.rectify.RectifyCalibrated)2 ListDisplayPanel (boofcv.gui.ListDisplayPanel)2 FDistort (boofcv.abst.distort.FDistort)1 ConfigGeneralDetector (boofcv.abst.feature.detect.interest.ConfigGeneralDetector)1 CalibrateStereoPlanar (boofcv.abst.geo.calibration.CalibrateStereoPlanar)1 ImageDistort (boofcv.alg.distort.ImageDistort)1 CreateSyntheticOverheadViewPL (boofcv.alg.sfm.overhead.CreateSyntheticOverheadViewPL)1