Search in sources :

Example 36 with Vector3D_F64

use of georegression.struct.point.Vector3D_F64 in project BoofCV by lessthanoptimal.

the class TriangulateLinearDLT method addView.

private int addView(Se3_F64 motion, Point2D_F64 a, int index) {
    DMatrixRMaj R = motion.getR();
    Vector3D_F64 T = motion.getT();
    double r11 = R.data[0], r12 = R.data[1], r13 = R.data[2];
    double r21 = R.data[3], r22 = R.data[4], r23 = R.data[5];
    double r31 = R.data[6], r32 = R.data[7], r33 = R.data[8];
    // no normalization of observations are needed since they are in normalized coordinates
    // first row
    A.data[index++] = a.x * r31 - r11;
    A.data[index++] = a.x * r32 - r12;
    A.data[index++] = a.x * r33 - r13;
    A.data[index++] = a.x * T.z - T.x;
    // second row
    A.data[index++] = a.y * r31 - r21;
    A.data[index++] = a.y * r32 - r22;
    A.data[index++] = a.y * r33 - r23;
    A.data[index++] = a.y * T.z - T.y;
    return index;
}
Also used : Vector3D_F64(georegression.struct.point.Vector3D_F64) DMatrixRMaj(org.ejml.data.DMatrixRMaj)

Example 37 with Vector3D_F64

use of georegression.struct.point.Vector3D_F64 in project BoofCV by lessthanoptimal.

the class CheckRefineFundamental method incorrectInput.

@Test
public void incorrectInput() {
    init(30, false);
    // compute true essential matrix
    DMatrixRMaj E = MultiViewOps.createEssential(worldToCamera.getR(), worldToCamera.getT());
    // create an alternative incorrect matrix
    Vector3D_F64 T = worldToCamera.getT().copy();
    T.x += 0.1;
    DMatrixRMaj Emod = MultiViewOps.createEssential(worldToCamera.getR(), T);
    ModelFitter<DMatrixRMaj, AssociatedPair> alg = createAlgorithm();
    // compute and compare results
    assertTrue(alg.fitModel(pairs, Emod, found));
    // normalize to allow comparison
    CommonOps_DDRM.divide(E, E.get(2, 2));
    CommonOps_DDRM.divide(Emod, Emod.get(2, 2));
    CommonOps_DDRM.divide(found, found.get(2, 2));
    double error0 = 0;
    double error1 = 0;
    // very crude error metric
    for (int i = 0; i < 9; i++) {
        error0 += Math.abs(Emod.data[i] - E.data[i]);
        error1 += Math.abs(found.data[i] - E.data[i]);
    }
    // System.out.println("error "+error1+"   other "+error0);
    assertTrue(error1 < error0);
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) Vector3D_F64(georegression.struct.point.Vector3D_F64) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Test(org.junit.Test)

Example 38 with Vector3D_F64

use of georegression.struct.point.Vector3D_F64 in project BoofCV by lessthanoptimal.

the class TestDetectCircleHexagonalGrid method checkCounterClockWise.

static void checkCounterClockWise(Grid g) {
    EllipseRotated_F64 a = g.get(0, 0);
    EllipseRotated_F64 b = g.columns >= 3 ? g.get(0, 2) : g.get(1, 1);
    EllipseRotated_F64 c = g.rows >= 3 ? g.get(2, 0) : g.get(1, 1);
    double dx0 = b.center.x - a.center.x;
    double dy0 = b.center.y - a.center.y;
    double dx1 = c.center.x - a.center.x;
    double dy1 = c.center.y - a.center.y;
    Vector3D_F64 v = new Vector3D_F64();
    GeometryMath_F64.cross(dx0, dy0, 0, dx1, dy1, 0, v);
    assertTrue(v.z > 0);
}
Also used : Vector3D_F64(georegression.struct.point.Vector3D_F64) EllipseRotated_F64(georegression.struct.curve.EllipseRotated_F64)

Example 39 with Vector3D_F64

use of georegression.struct.point.Vector3D_F64 in project BoofCV by lessthanoptimal.

the class ExampleVisualOdometryDepth method main.

public static void main(String[] args) throws IOException {
    MediaManager media = DefaultMediaManager.INSTANCE;
    String directory = UtilIO.pathExample("kinect/straight");
    // load camera description and the video sequence
    VisualDepthParameters param = CalibrationIO.load(media.openFile(directory + "visualdepth.yaml"));
    // 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);
    DepthSparse3D<GrayU16> sparseDepth = new DepthSparse3D.I<>(1e-3);
    // declares the algorithm
    DepthVisualOdometry<GrayU8, GrayU16> visualOdometry = FactoryVisualOdometry.depthDepthPnP(1.5, 120, 2, 200, 50, true, sparseDepth, tracker, GrayU8.class, GrayU16.class);
    // Pass in intrinsic/extrinsic calibration.  This can be changed in the future.
    visualOdometry.setCalibration(param.visualParam, new DoNothing2Transform2_F32());
    // Process the video sequence and output the location plus number of inliers
    SimpleImageSequence<GrayU8> videoVisual = media.openVideo(directory + "rgb.mjpeg", ImageType.single(GrayU8.class));
    SimpleImageSequence<GrayU16> videoDepth = media.openVideo(directory + "depth.mpng", ImageType.single(GrayU16.class));
    while (videoVisual.hasNext()) {
        GrayU8 visual = videoVisual.next();
        GrayU16 depth = videoDepth.next();
        if (!visualOdometry.process(visual, depth)) {
            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 : VisualDepthParameters(boofcv.struct.calib.VisualDepthParameters) GrayU16(boofcv.struct.image.GrayU16) PkltConfig(boofcv.alg.tracker.klt.PkltConfig) ConfigGeneralDetector(boofcv.abst.feature.detect.interest.ConfigGeneralDetector) DoNothing2Transform2_F32(boofcv.struct.distort.DoNothing2Transform2_F32) Vector3D_F64(georegression.struct.point.Vector3D_F64) MediaManager(boofcv.io.MediaManager) DefaultMediaManager(boofcv.io.wrapper.DefaultMediaManager) GrayU8(boofcv.struct.image.GrayU8) Se3_F64(georegression.struct.se.Se3_F64)

Example 40 with Vector3D_F64

use of georegression.struct.point.Vector3D_F64 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)

Aggregations

Vector3D_F64 (georegression.struct.point.Vector3D_F64)60 DMatrixRMaj (org.ejml.data.DMatrixRMaj)34 Se3_F64 (georegression.struct.se.Se3_F64)30 Test (org.junit.Test)23 Point3D_F64 (georegression.struct.point.Point3D_F64)15 Point2D_F64 (georegression.struct.point.Point2D_F64)13 ConfigGeneralDetector (boofcv.abst.feature.detect.interest.ConfigGeneralDetector)4 PkltConfig (boofcv.alg.tracker.klt.PkltConfig)4 GrayU8 (boofcv.struct.image.GrayU8)4 MediaManager (boofcv.io.MediaManager)3 DefaultMediaManager (boofcv.io.wrapper.DefaultMediaManager)3 ArrayList (java.util.ArrayList)3 GrayU16 (boofcv.struct.image.GrayU16)2 UtilVector3D_F64 (georegression.geometry.UtilVector3D_F64)2 GeometryUnitTest (georegression.misc.test.GeometryUnitTest)2 EllipseRotated_F64 (georegression.struct.curve.EllipseRotated_F64)2 Random (java.util.Random)2 SimpleMatrix (org.ejml.simple.SimpleMatrix)2 ConfigChessboard (boofcv.abst.fiducial.calib.ConfigChessboard)1 AccessPointTracks3D (boofcv.abst.sfm.AccessPointTracks3D)1