Search in sources :

Example 26 with FastQueue

use of org.ddogleg.struct.FastQueue in project BoofCV by lessthanoptimal.

the class TestVisualDepthOps method depthTo3D.

@Test
public void depthTo3D() {
    GrayU16 depth = new GrayU16(width, height);
    depth.set(200, 80, 3400);
    depth.set(600, 420, 50);
    FastQueue<Point3D_F64> pts = new FastQueue<>(Point3D_F64.class, true);
    VisualDepthOps.depthTo3D(param, depth, pts);
    assertEquals(2, pts.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);
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) GrayU16(boofcv.struct.image.GrayU16) FastQueue(org.ddogleg.struct.FastQueue) Test(org.junit.Test)

Example 27 with FastQueue

use of org.ddogleg.struct.FastQueue 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

FastQueue (org.ddogleg.struct.FastQueue)27 Test (org.junit.Test)17 Point3D_F64 (georegression.struct.point.Point3D_F64)9 GrayU16 (boofcv.struct.image.GrayU16)5 GrayU8 (boofcv.struct.image.GrayU8)5 GrowQueue_I32 (org.ddogleg.struct.GrowQueue_I32)5 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)4 FastQueueArray_I32 (boofcv.struct.FastQueueArray_I32)4 Point2D_F64 (georegression.struct.point.Point2D_F64)4 Point2D_I32 (georegression.struct.point.Point2D_I32)4 BufferedImage (java.awt.image.BufferedImage)4 ArrayList (java.util.ArrayList)4 DMatrixRMaj (org.ejml.data.DMatrixRMaj)4 BrightFeature (boofcv.struct.feature.BrightFeature)3 GrayS32 (boofcv.struct.image.GrayS32)3 File (java.io.File)3 DetectDescribePoint (boofcv.abst.feature.detdesc.DetectDescribePoint)2 Edge (boofcv.alg.segmentation.fh04.SegmentFelzenszwalbHuttenlocher04.Edge)2 PointCloudViewer (boofcv.gui.d3.PointCloudViewer)2 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)2