Search in sources :

Example 1 with PointCloudViewerPanel

use of boofcv.gui.PointCloudViewerPanel in project BoofCV by lessthanoptimal.

the class ExampleViewPointCloud method main.

public static void main(String[] args) throws IOException {
    String filePath = UtilIO.pathExample("mvs/stone_sign.ply");
    // Load the PLY file
    var cloud = new DogArray<>(Point3dRgbI_F32::new);
    PointCloudIO.load(PointCloudIO.Format.PLY, new FileInputStream(filePath), PointCloudWriter.wrapF32RGB(cloud));
    System.out.println("Total Points " + cloud.size);
    // Create the 3D viewer as a Swing panel that will have some minimal controls for adjusting the clouds
    // appearance. Since a software render is used it will get a bit sluggish (on my computer)
    // around 1,000,000 points
    PointCloudViewerPanel viewerPanel = new PointCloudViewerPanel();
    viewerPanel.setPreferredSize(new Dimension(800, 600));
    PointCloudViewer viewer = viewerPanel.getViewer();
    // Change the camera's Field-of-View
    viewer.setCameraHFov(UtilAngle.radian(60));
    // So many formats to store a 3D point and color that a functional API is used here
    viewer.addCloud((idx, p) -> ConvertFloatType.convert(cloud.get(idx), p), (idx) -> cloud.get(idx).rgb, cloud.size);
    // There are a ton of options for the viewer, but we will let the GUI handle most of them
    // Alternatively, you could use VisualizeData.createPointCloudViewer(). No controls are
    // provided if you use that.
    SwingUtilities.invokeLater(() -> {
        viewerPanel.handleControlChange();
        viewerPanel.repaint();
        ShowImages.showWindow(viewerPanel, "Point Cloud", true);
    });
}
Also used : PointCloudViewer(boofcv.visualize.PointCloudViewer) Point3dRgbI_F32(boofcv.struct.Point3dRgbI_F32) DogArray(org.ddogleg.struct.DogArray) FileInputStream(java.io.FileInputStream) PointCloudViewerPanel(boofcv.gui.PointCloudViewerPanel)

Aggregations

PointCloudViewerPanel (boofcv.gui.PointCloudViewerPanel)1 Point3dRgbI_F32 (boofcv.struct.Point3dRgbI_F32)1 PointCloudViewer (boofcv.visualize.PointCloudViewer)1 FileInputStream (java.io.FileInputStream)1 DogArray (org.ddogleg.struct.DogArray)1