Search in sources :

Example 21 with StereoParameters

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

the class TestPnPStereoResidualReprojection method compareToReprojection.

@Test
public void compareToReprojection() {
    Se3_F64 worldToLeft = new Se3_F64();
    ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.1, 1, -0.2, worldToLeft.getR());
    worldToLeft.getT().set(-0.3, 0.4, 1);
    generateScene(10, worldToLeft, false);
    // make the input model incorrect
    worldToLeft.getR().set(2, 1, 2);
    // compute the error in normalized image coordinates per element
    PnPStereoResidualReprojection alg = new PnPStereoResidualReprojection();
    alg.setModel(new StereoPose(worldToLeft, leftToRight));
    // compute errors with perfect model
    double[] error = new double[alg.getN()];
    alg.computeResiduals(pointPose.get(0), error, 0);
    double found = 0;
    for (double e : error) {
        found += e * e;
    }
    PnPStereoDistanceReprojectionSq validation = new PnPStereoDistanceReprojectionSq();
    StereoParameters param = new StereoParameters();
    param.rightToLeft = this.param.rightToLeft;
    // intrinsic parameters are configured to be identical to normalized image coordinates
    param.left = new CameraPinholeRadial(1, 1, 0, 0, 0, 0, 0).fsetRadial(0, 0);
    param.right = new CameraPinholeRadial(1, 1, 0, 0, 0, 0, 0).fsetRadial(0, 0);
    validation.setStereoParameters(param);
    validation.setModel(worldToLeft);
    double expected = validation.computeDistance(pointPose.get(0));
    assertEquals(expected, found, 1e-8);
}
Also used : StereoPose(boofcv.struct.sfm.StereoPose) CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) StereoParameters(boofcv.struct.calib.StereoParameters) Se3_F64(georegression.struct.se.Se3_F64) Test(org.junit.Test)

Example 22 with StereoParameters

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

the class TestCalibrateStereoPlanar method fullBasic.

/**
 * Give it a fake feature detector and a fairly benign scenario and see if it can correctly
 * estimate the camera parameters.
 */
@Test
public void fullBasic() {
    CalibrateStereoPlanar alg = new CalibrateStereoPlanar(layout);
    alg.configure(true, 2, true);
    for (int i = 0; i < targetToLeft.size(); i++) {
        alg.addPair(createFakeObservations(i, true), createFakeObservations(i, false));
    }
    StereoParameters found = alg.process();
    checkIntrinsic(found.left);
    checkIntrinsic(found.right);
    Se3_F64 rightToLeft = found.getRightToLeft();
    Se3_F64 expected = leftToRight.invert(null);
    assertEquals(0, expected.getT().distance(rightToLeft.T), 1.01e-3);
    assertTrue(MatrixFeatures_DDRM.isIdentity(rightToLeft.getR(), 1e-3));
}
Also used : StereoParameters(boofcv.struct.calib.StereoParameters) Se3_F64(georegression.struct.se.Se3_F64) Test(org.junit.Test)

Example 23 with StereoParameters

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

the class CheckVisualOdometryStereoSim method changeInputSize.

@Test
public void changeInputSize() {
    StereoVisualOdometry<I> algorithm = createAlgorithm();
    I leftSmall = GeneralizedImageOps.createSingleBand(inputType, width / 2, height / 2);
    I rightSmall = GeneralizedImageOps.createSingleBand(inputType, width / 2, height / 2);
    I leftLarge = GeneralizedImageOps.createSingleBand(inputType, width, height);
    I rightLarge = GeneralizedImageOps.createSingleBand(inputType, width, height);
    GImageMiscOps.fillUniform(leftSmall, rand, 0, 100);
    GImageMiscOps.fillUniform(leftSmall, rand, 0, 100);
    GImageMiscOps.fillUniform(leftLarge, rand, 0, 100);
    GImageMiscOps.fillUniform(rightLarge, rand, 0, 100);
    StereoParameters paramSmall = createStereoParam();
    paramSmall.left.width = paramSmall.right.width = leftSmall.width;
    paramSmall.left.height = paramSmall.right.height = leftSmall.height;
    algorithm.setCalibration(paramSmall);
    algorithm.process(leftSmall, rightSmall);
    StereoParameters paramLarge = createStereoParam();
    paramLarge.left.width = paramLarge.right.width = leftLarge.width;
    paramLarge.left.height = paramLarge.right.height = leftLarge.height;
    algorithm.setCalibration(paramLarge);
    algorithm.process(leftLarge, rightSmall);
}
Also used : StereoParameters(boofcv.struct.calib.StereoParameters) Test(org.junit.Test)

Example 24 with StereoParameters

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

the class TestStereoVisualOdometryScaleInput method process.

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

Example 25 with StereoParameters

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

the class TestStereoVisualOdometryScaleInput method getImageType.

@Test
public void getImageType() {
    StereoParameters p = createStereoParam();
    Dummy dummy = new Dummy();
    StereoVisualOdometryScaleInput<GrayF32> alg = new StereoVisualOdometryScaleInput<>(dummy, 0.5);
    assertTrue(type == alg.getImageType());
}
Also used : GrayF32(boofcv.struct.image.GrayF32) StereoParameters(boofcv.struct.calib.StereoParameters) Test(org.junit.Test)

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