Search in sources :

Example 1 with MonoPlaneParameters

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

the class CheckVisualOdometryMonoPlaneSim method motionCheck.

public void motionCheck(double angleRate, double forwardRate) {
    // Easier to make up a plane in this direction
    Se3_F64 cameraToPlane = new Se3_F64();
    ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, UtilAngle.degreeToRadian(cameraAngle), 0.1, 0.0, cameraToPlane.getR());
    cameraToPlane.getT().set(0, -2, 0);
    Se3_F64 planeToCamera = cameraToPlane.invert(null);
    Se3_F64 worldToCurr = new Se3_F64();
    Se3_F64 worldToCamera = new Se3_F64();
    algorithm.reset();
    algorithm.setCalibration(new MonoPlaneParameters(param, planeToCamera));
    for (int i = 0; i < 10; i++) {
        // System.out.println("-------- Real rotY = "+angleRate*i);
        // move forward
        worldToCurr.getT().z = -i * forwardRate;
        ConvertRotation3D_F64.rotY(angleRate * i, worldToCurr.getR());
        worldToCurr.concat(planeToCamera, worldToCamera);
        // render the images
        setIntrinsic(param);
        left.setTo(render(worldToCamera));
        // process the images
        assertTrue(algorithm.process(left));
        // Compare to truth.  Only go for a crude approximation
        Se3_F64 foundWorldToCamera = algorithm.getCameraToWorld().invert(null);
        Se3_F64 foundWorldToCurr = foundWorldToCamera.concat(cameraToPlane, null);
        // worldToCurr.getT().print();
        // foundWorldToCurr.getT().print();
        // worldToCurr.getR().print();
        // foundWorldToCurr.getR().print();
        assertTrue(MatrixFeatures_DDRM.isIdentical(foundWorldToCurr.getR(), worldToCurr.getR(), 0.1));
        assertTrue(foundWorldToCurr.getT().distance(worldToCurr.getT()) < tolerance);
    }
}
Also used : MonoPlaneParameters(boofcv.struct.calib.MonoPlaneParameters) Se3_F64(georegression.struct.se.Se3_F64)

Example 2 with MonoPlaneParameters

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

the class TestMonocularPlaneVisualOdometryScaleInput method setCalibration.

@Test
public void setCalibration() {
    param = null;
    CameraPinholeRadial intrinsic = createIntrinsic();
    Se3_F64 extrinsic = new Se3_F64();
    extrinsic.T.x = 8;
    Dummy dummy = new Dummy();
    MonocularPlaneVisualOdometry<GrayF32> alg = new MonocularPlaneVisualOdometryScaleInput<>(dummy, 0.5);
    assertTrue(this.param == null);
    alg.setCalibration(new MonoPlaneParameters(intrinsic, extrinsic));
    assertEquals(320, this.param.intrinsic.width);
    assertEquals(160, this.param.intrinsic.height);
    assertTrue(this.param.planeToCamera.T.x == extrinsic.T.x);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) MonoPlaneParameters(boofcv.struct.calib.MonoPlaneParameters) Se3_F64(georegression.struct.se.Se3_F64) Test(org.junit.Test)

Example 3 with MonoPlaneParameters

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

the class ExampleVisualOdometryMonocularPlane method main.

public static void main(String[] args) {
    MediaManager media = DefaultMediaManager.INSTANCE;
    String directory = UtilIO.pathExample("vo/drc/");
    // load camera description and the video sequence
    MonoPlaneParameters calibration = CalibrationIO.load(media.openFile(directory + "mono_plane.yaml"));
    SimpleImageSequence<GrayU8> video = media.openVideo(directory + "left.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;
    ConfigGeneralDetector configDetector = new ConfigGeneralDetector(600, 3, 1);
    PointTracker<GrayU8> tracker = FactoryPointTracker.klt(configKlt, configDetector, GrayU8.class, null);
    // declares the algorithm
    MonocularPlaneVisualOdometry<GrayU8> visualOdometry = FactoryVisualOdometry.monoPlaneInfinity(75, 2, 1.5, 200, tracker, ImageType.single(GrayU8.class));
    // Pass in intrinsic/extrinsic calibration.  This can be changed in the future.
    visualOdometry.setCalibration(calibration);
    // Process the video sequence and output the location plus number of inliers
    while (video.hasNext()) {
        GrayU8 image = video.next();
        if (!visualOdometry.process(image)) {
            System.out.println("Fault!");
            visualOdometry.reset();
        }
        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 : Vector3D_F64(georegression.struct.point.Vector3D_F64) PkltConfig(boofcv.alg.tracker.klt.PkltConfig) MediaManager(boofcv.io.MediaManager) DefaultMediaManager(boofcv.io.wrapper.DefaultMediaManager) ConfigGeneralDetector(boofcv.abst.feature.detect.interest.ConfigGeneralDetector) GrayU8(boofcv.struct.image.GrayU8) MonoPlaneParameters(boofcv.struct.calib.MonoPlaneParameters) Se3_F64(georegression.struct.se.Se3_F64)

Example 4 with MonoPlaneParameters

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

the class TestMonocularPlaneVisualOdometryScaleInput method process.

@Test
public void process() {
    image = null;
    CameraPinholeRadial intrinsic = createIntrinsic();
    Dummy dummy = new Dummy();
    MonocularPlaneVisualOdometry<GrayF32> alg = new MonocularPlaneVisualOdometryScaleInput<>(dummy, 0.5);
    alg.setCalibration(new MonoPlaneParameters(intrinsic, new Se3_F64()));
    GrayF32 inputImage = new GrayF32(width, height);
    alg.process(inputImage);
    assertTrue(inputImage != image);
    assertEquals(320, image.width);
    assertEquals(160, image.height);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) MonoPlaneParameters(boofcv.struct.calib.MonoPlaneParameters) Se3_F64(georegression.struct.se.Se3_F64) Test(org.junit.Test)

Aggregations

MonoPlaneParameters (boofcv.struct.calib.MonoPlaneParameters)4 Se3_F64 (georegression.struct.se.Se3_F64)4 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)2 GrayF32 (boofcv.struct.image.GrayF32)2 Test (org.junit.Test)2 ConfigGeneralDetector (boofcv.abst.feature.detect.interest.ConfigGeneralDetector)1 PkltConfig (boofcv.alg.tracker.klt.PkltConfig)1 MediaManager (boofcv.io.MediaManager)1 DefaultMediaManager (boofcv.io.wrapper.DefaultMediaManager)1 GrayU8 (boofcv.struct.image.GrayU8)1 Vector3D_F64 (georegression.struct.point.Vector3D_F64)1