Search in sources :

Example 1 with RemoveRadialPtoN_F64

use of boofcv.alg.distort.radtan.RemoveRadialPtoN_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)

Example 2 with RemoveRadialPtoN_F64

use of boofcv.alg.distort.radtan.RemoveRadialPtoN_F64 in project BoofCV by lessthanoptimal.

the class TestVisualDepthOps method compute.

private Point3D_F64 compute(int x, int y, int distance) {
    Point2D_F64 n = new Point2D_F64();
    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);
    p2n.compute(x, y, n);
    Point3D_F64 p = new Point3D_F64();
    p.z = distance;
    p.x = n.x * p.z;
    p.y = n.y * p.z;
    return p;
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) Point2D_F64(georegression.struct.point.Point2D_F64) RemoveRadialPtoN_F64(boofcv.alg.distort.radtan.RemoveRadialPtoN_F64)

Aggregations

RemoveRadialPtoN_F64 (boofcv.alg.distort.radtan.RemoveRadialPtoN_F64)2 Point2D_F64 (georegression.struct.point.Point2D_F64)2 Point3D_F64 (georegression.struct.point.Point3D_F64)2 GrayU8 (boofcv.struct.image.GrayU8)1