Search in sources :

Example 1 with FastQueueArray_I32

use of boofcv.struct.FastQueueArray_I32 in project BoofCV by lessthanoptimal.

the class TestVisualDepthOps method depthTo3D_with_rgb.

@Test
public void depthTo3D_with_rgb() {
    GrayU16 depth = new GrayU16(width, height);
    depth.set(200, 80, 3400);
    depth.set(600, 420, 50);
    Planar<GrayU8> rgb = new Planar<>(GrayU8.class, width, height, 3);
    GImageMiscOps.fillUniform(rgb, rand, 0, 200);
    FastQueue<Point3D_F64> pts = new FastQueue<>(Point3D_F64.class, true);
    FastQueueArray_I32 color = new FastQueueArray_I32(3);
    VisualDepthOps.depthTo3D(param, rgb, depth, pts, color);
    assertEquals(2, pts.size());
    assertEquals(2, color.size());
    assertEquals(0, compute(200, 80, 3400).distance(pts.get(0)), 1e-8);
    assertEquals(0, compute(600, 420, 50).distance(pts.get(1)), 1e-8);
    color(200, 80, rgb, color.get(0));
    color(600, 420, rgb, color.get(1));
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) GrayU16(boofcv.struct.image.GrayU16) FastQueue(org.ddogleg.struct.FastQueue) Planar(boofcv.struct.image.Planar) GrayU8(boofcv.struct.image.GrayU8) FastQueueArray_I32(boofcv.struct.FastQueueArray_I32) Test(org.junit.Test)

Example 2 with FastQueueArray_I32

use of boofcv.struct.FastQueueArray_I32 in project BoofCV by lessthanoptimal.

the class CreateRgbPointCloudFileApp method main.

public static void main(String[] args) throws IOException {
    String baseDir = "log/";
    String nameRgb = baseDir + "rgb0000000.ppm";
    String nameDepth = baseDir + "depth0000000.depth";
    String nameCalib = baseDir + "intrinsic.yaml";
    CameraPinholeRadial param = CalibrationIO.load(nameCalib);
    GrayU16 depth = new GrayU16(1, 1);
    Planar<GrayU8> rgb = new Planar<>(GrayU8.class, 1, 1, 3);
    UtilImageIO.loadPPM_U8(nameRgb, rgb, null);
    UtilOpenKinect.parseDepth(nameDepth, depth, null);
    FastQueue<Point3D_F64> cloud = new FastQueue<Point3D_F64>(Point3D_F64.class, true);
    FastQueueArray_I32 cloudColor = new FastQueueArray_I32(3);
    VisualDepthOps.depthTo3D(param, rgb, depth, cloud, cloudColor);
    DataOutputStream file = new DataOutputStream(new FileOutputStream("kinect_pointcloud.txt"));
    file.write("# Kinect RGB Point cloud. Units: millimeters. Format: X Y Z R G B\n".getBytes());
    for (int i = 0; i < cloud.size; i++) {
        Point3D_F64 p = cloud.get(i);
        int[] color = cloudColor.get(i);
        String line = String.format("%.10f %.10f %.10f %d %d %d\n", p.x, p.y, p.z, color[0], color[1], color[2]);
        file.write(line.getBytes());
    }
    file.close();
    System.out.println("Total points = " + cloud.size);
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) GrayU16(boofcv.struct.image.GrayU16) FastQueue(org.ddogleg.struct.FastQueue) DataOutputStream(java.io.DataOutputStream) FastQueueArray_I32(boofcv.struct.FastQueueArray_I32) CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) FileOutputStream(java.io.FileOutputStream) Planar(boofcv.struct.image.Planar) GrayU8(boofcv.struct.image.GrayU8)

Example 3 with FastQueueArray_I32

use of boofcv.struct.FastQueueArray_I32 in project BoofCV by lessthanoptimal.

the class DisplayKinectPointCloudApp method main.

public static void main(String[] args) throws IOException {
    String baseDir = UtilIO.pathExample("kinect/basket");
    String nameRgb = "basket_rgb.png";
    String nameDepth = "basket_depth.png";
    String nameCalib = "intrinsic.yaml";
    CameraPinholeRadial param = CalibrationIO.load(new File(baseDir, nameCalib));
    GrayU16 depth = UtilImageIO.loadImage(new File(baseDir, nameDepth), false, ImageType.single(GrayU16.class));
    Planar<GrayU8> rgb = UtilImageIO.loadImage(new File(baseDir, nameRgb), true, ImageType.pl(3, GrayU8.class));
    FastQueue<Point3D_F64> cloud = new FastQueue<Point3D_F64>(Point3D_F64.class, true);
    FastQueueArray_I32 cloudColor = new FastQueueArray_I32(3);
    VisualDepthOps.depthTo3D(param, rgb, depth, cloud, cloudColor);
    DMatrixRMaj K = PerspectiveOps.calibrationMatrix(param, (DMatrixRMaj) null);
    PointCloudViewer viewer = new PointCloudViewer(K, 10.0);
    viewer.setPreferredSize(new Dimension(rgb.width, rgb.height));
    for (int i = 0; i < cloud.size; i++) {
        Point3D_F64 p = cloud.get(i);
        int[] color = cloudColor.get(i);
        int c = (color[0] << 16) | (color[1] << 8) | color[2];
        viewer.addPoint(p.x, p.y, p.z, c);
    }
    ShowImages.showWindow(viewer, "Point Cloud", true);
    System.out.println("Total points = " + cloud.size);
// BufferedImage depthOut = VisualizeImageData.disparity(depth, null, 0, UtilOpenKinect.FREENECT_DEPTH_MM_MAX_VALUE, 0);
// ShowImages.showWindow(depthOut,"Depth Image", true);
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) GrayU16(boofcv.struct.image.GrayU16) FastQueue(org.ddogleg.struct.FastQueue) DMatrixRMaj(org.ejml.data.DMatrixRMaj) FastQueueArray_I32(boofcv.struct.FastQueueArray_I32) CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) PointCloudViewer(boofcv.gui.d3.PointCloudViewer) GrayU8(boofcv.struct.image.GrayU8) File(java.io.File)

Example 4 with FastQueueArray_I32

use of boofcv.struct.FastQueueArray_I32 in project BoofCV by lessthanoptimal.

the class ExampleDepthPointCloud method main.

public static void main(String[] args) throws IOException {
    String nameRgb = UtilIO.pathExample("kinect/basket/basket_rgb.png");
    String nameDepth = UtilIO.pathExample("kinect/basket/basket_depth.png");
    String nameCalib = UtilIO.pathExample("kinect/basket/visualdepth.yaml");
    VisualDepthParameters param = CalibrationIO.load(nameCalib);
    BufferedImage buffered = UtilImageIO.loadImage(nameRgb);
    Planar<GrayU8> rgb = ConvertBufferedImage.convertFromPlanar(buffered, null, true, GrayU8.class);
    GrayU16 depth = ConvertBufferedImage.convertFrom(UtilImageIO.loadImage(nameDepth), null, GrayU16.class);
    FastQueue<Point3D_F64> cloud = new FastQueue<>(Point3D_F64.class, true);
    FastQueueArray_I32 cloudColor = new FastQueueArray_I32(3);
    VisualDepthOps.depthTo3D(param.visualParam, rgb, depth, cloud, cloudColor);
    DMatrixRMaj K = PerspectiveOps.calibrationMatrix(param.visualParam, (DMatrixRMaj) null);
    PointCloudViewer viewer = new PointCloudViewer(K, 15);
    viewer.setPreferredSize(new Dimension(rgb.width, rgb.height));
    for (int i = 0; i < cloud.size; i++) {
        Point3D_F64 p = cloud.get(i);
        int[] color = cloudColor.get(i);
        int c = (color[0] << 16) | (color[1] << 8) | color[2];
        viewer.addPoint(p.x, p.y, p.z, c);
    }
    // ---------- Display depth image
    // use the actual max value in the image to maximize its appearance
    int maxValue = ImageStatistics.max(depth);
    BufferedImage depthOut = VisualizeImageData.disparity(depth, null, 0, maxValue, 0);
    ShowImages.showWindow(depthOut, "Depth Image");
    // ---------- Display colorized point cloud
    ShowImages.showWindow(viewer, "Point Cloud");
    System.out.println("Total points = " + cloud.size);
}
Also used : VisualDepthParameters(boofcv.struct.calib.VisualDepthParameters) Point3D_F64(georegression.struct.point.Point3D_F64) GrayU16(boofcv.struct.image.GrayU16) FastQueue(org.ddogleg.struct.FastQueue) DMatrixRMaj(org.ejml.data.DMatrixRMaj) FastQueueArray_I32(boofcv.struct.FastQueueArray_I32) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage) PointCloudViewer(boofcv.gui.d3.PointCloudViewer) GrayU8(boofcv.struct.image.GrayU8)

Aggregations

FastQueueArray_I32 (boofcv.struct.FastQueueArray_I32)4 GrayU16 (boofcv.struct.image.GrayU16)4 GrayU8 (boofcv.struct.image.GrayU8)4 Point3D_F64 (georegression.struct.point.Point3D_F64)4 FastQueue (org.ddogleg.struct.FastQueue)4 PointCloudViewer (boofcv.gui.d3.PointCloudViewer)2 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)2 Planar (boofcv.struct.image.Planar)2 DMatrixRMaj (org.ejml.data.DMatrixRMaj)2 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)1 VisualDepthParameters (boofcv.struct.calib.VisualDepthParameters)1 BufferedImage (java.awt.image.BufferedImage)1 DataOutputStream (java.io.DataOutputStream)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 Test (org.junit.Test)1