Search in sources :

Example 61 with Point2D_F64

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

the class GeneralLensDistortionNarrowFOVChecks method forwardsBackwards_F64.

@Test
public void forwardsBackwards_F64() {
    LensDistortionNarrowFOV alg = create();
    for (int i = 0; i < 4; i++) {
        boolean inputPixel = i % 2 == 0;
        boolean outputPixel = i / 2 == 0;
        Point2Transform2_F64 distort = alg.distort_F64(inputPixel, outputPixel);
        Point2Transform2_F64 undistort = alg.undistort_F64(outputPixel, inputPixel);
        double inputX, inputY, scale;
        if (inputPixel) {
            inputX = 21.3;
            inputY = 45.1;
            scale = 10.0;
        } else {
            inputX = 0.05;
            inputY = -0.1;
            scale = 0.1;
        }
        Point2D_F64 middle = new Point2D_F64();
        Point2D_F64 found = new Point2D_F64();
        distort.compute(inputX, inputY, middle);
        undistort.compute(middle.x, middle.y, found);
        assertEquals(inputX, found.x, scale * tol_F64);
        assertEquals(inputY, found.y, scale * tol_F64);
    }
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) Point2Transform2_F64(boofcv.struct.distort.Point2Transform2_F64) Test(org.junit.Test)

Example 62 with Point2D_F64

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

the class TestFlipVerticalNorm_F64 method theSuperDuperTest.

@Test
public void theSuperDuperTest() {
    FlipVerticalNorm2_F64 alg = new FlipVerticalNorm2_F64(new Dummy(), 1);
    Point2D_F64 out = new Point2D_F64();
    alg.compute(2, 3, out);
    assertEquals(2, out.x, 1e-8);
    assertEquals(3, -out.y, 1e-8);
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) Test(org.junit.Test)

Example 63 with Point2D_F64

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

the class TestFlipVertical_F64 method basicTest.

@Test
public void basicTest() {
    FlipVertical_F64 alg = new FlipVertical_F64(100);
    Point2D_F64 found = new Point2D_F64();
    alg.compute(20, 30, found);
    assertEquals(20, found.x, 1e-8);
    assertEquals(100 - 30 - 1, found.y, 1e-8);
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) Test(org.junit.Test)

Example 64 with Point2D_F64

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

the class VisOdomPixelDepthPnP method performSecondPass.

private boolean performSecondPass(List<PointTrack> active, List<Point2D3D> obs) {
    Se3_F64 keyToCurr = motionEstimator.getModelParameters();
    Point3D_F64 cameraPt = new Point3D_F64();
    Point2D_F64 predicted = new Point2D_F64();
    // predict where each track should be given the just estimated motion
    List<PointTrack> all = tracker.getAllTracks(null);
    for (PointTrack t : all) {
        Point2D3D p = t.getCookie();
        SePointOps_F64.transform(keyToCurr, p.location, cameraPt);
        normToPixel.compute(cameraPt.x / cameraPt.z, cameraPt.y / cameraPt.z, predicted);
        tracker.setHint(predicted.x, predicted.y, t);
    }
    // redo tracking with the additional information
    tracker.performSecondPass();
    active.clear();
    obs.clear();
    tracker.getActiveTracks(active);
    for (PointTrack t : active) {
        Point2D3D p = t.getCookie();
        pixelToNorm.compute(t.x, t.y, p.observation);
        obs.add(p);
    }
    return motionEstimator.process(obs);
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) Point2D3D(boofcv.struct.geo.Point2D3D) PointTrack(boofcv.abst.feature.tracker.PointTrack) Point2D_F64(georegression.struct.point.Point2D_F64) Se3_F64(georegression.struct.se.Se3_F64)

Example 65 with Point2D_F64

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

the class VisualDepthOps method depthTo3D.

/**
 * Creates a point cloud from a depth image and saves the color information.  The depth and color images are
 * assumed to be aligned.
 * @param param Intrinsic camera parameters for depth image
 * @param depth depth image.  each value is in millimeters.
 * @param rgb Color image that's aligned to the depth.
 * @param cloud Output point cloud
 * @param cloudColor Output color for each point in the cloud
 */
public static void depthTo3D(CameraPinholeRadial param, Planar<GrayU8> rgb, GrayU16 depth, FastQueue<Point3D_F64> cloud, FastQueueArray_I32 cloudColor) {
    cloud.reset();
    cloudColor.reset();
    RemoveRadialPtoN_F64 p2n = new RemoveRadialPtoN_F64();
    p2n.setK(param.fx, param.fy, param.skew, param.cx, param.cy).setDistortion(param.radial, param.t1, param.t2);
    Point2D_F64 n = new Point2D_F64();
    GrayU8 colorR = rgb.getBand(0);
    GrayU8 colorG = rgb.getBand(1);
    GrayU8 colorB = rgb.getBand(2);
    for (int y = 0; y < depth.height; y++) {
        int index = depth.startIndex + y * depth.stride;
        for (int x = 0; x < depth.width; x++) {
            int mm = depth.data[index++] & 0xFFFF;
            // skip pixels with no depth information
            if (mm == 0)
                continue;
            // this could all be precomputed to speed it up
            p2n.compute(x, y, n);
            Point3D_F64 p = cloud.grow();
            p.z = mm;
            p.x = n.x * p.z;
            p.y = n.y * p.z;
            int[] color = cloudColor.grow();
            color[0] = colorR.unsafe_get(x, y);
            color[1] = colorG.unsafe_get(x, y);
            color[2] = colorB.unsafe_get(x, y);
        }
    }
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) Point2D_F64(georegression.struct.point.Point2D_F64) GrayU8(boofcv.struct.image.GrayU8) RemoveRadialPtoN_F64(boofcv.alg.distort.radtan.RemoveRadialPtoN_F64)

Aggregations

Point2D_F64 (georegression.struct.point.Point2D_F64)360 Test (org.junit.Test)129 Point3D_F64 (georegression.struct.point.Point3D_F64)85 Se3_F64 (georegression.struct.se.Se3_F64)68 ArrayList (java.util.ArrayList)57 DMatrixRMaj (org.ejml.data.DMatrixRMaj)48 AssociatedPair (boofcv.struct.geo.AssociatedPair)28 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)16 Point2Transform2_F64 (boofcv.struct.distort.Point2Transform2_F64)15 GrayF32 (boofcv.struct.image.GrayF32)13 Vector3D_F64 (georegression.struct.point.Vector3D_F64)13 Polygon2D_F64 (georegression.struct.shapes.Polygon2D_F64)13 Point2D3D (boofcv.struct.geo.Point2D3D)11 GrayU8 (boofcv.struct.image.GrayU8)11 Point2D_I32 (georegression.struct.point.Point2D_I32)11 AssociatedIndex (boofcv.struct.feature.AssociatedIndex)10 EllipseRotated_F64 (georegression.struct.curve.EllipseRotated_F64)9 DescribeRegionPoint (boofcv.abst.feature.describe.DescribeRegionPoint)8 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)8 BufferedImage (java.awt.image.BufferedImage)8