isra m
isra m

Reputation: 1

Difficulty in Loading and Visualizing Point Cloud Files in Various Formats and Implementing Interactive Cutting Feature

I'm currently working on a project where I need to load point cloud files of various formats (mainly LAS, LAZ, PLY) and visualize them. Specifically, I've managed to load PLY files using Python's Open3D library. However, I'm encountering difficulties in loading other formats and rendering the results on the web platform. Additionally, I'm aiming to implement an interactive cutting feature where users can use the mouse or provide exact coordinates to cut the point cloud, for example, isolating specific floors of a building.

So far, I've successfully loaded PLY files using Open3D in Python, which met my expectations. However, I'm struggling to find a suitable approach or library to load LAS, LAZ, and potentially other point cloud formats. Additionally, I'm unsure about the best practices for rendering these point clouds on the web platform:, when attempting to extend this capability to other formats and integrate it into a web-based environment using Three.js, I encountered significant hurdles. As for the cutting feature, I've explored some basic geometric algorithms, but I'm uncertain about the most efficient and accurate method to implement this interactive cutting functionality.

Upvotes: 0

Views: 700

Answers (1)

Rejexx
Rejexx

Reputation: 69

To open LAS and LAZ you'll need a different package. I use laspy, open the files then manually convert them into the format open3d wants. It's surprising open3d can't open LAS/Z files yet, I use this function.

import laspy 
import open3d as o3d
import numpy as np


def laspy_to_o3d(las: laspy.lasdata) -> o3d.t.geometry.PointCloud:
    # get points
    points = np.vstack((las.x, las.y, las.z)).transpose()

    # make blank cloud
    pcd_t = o3d.t.geometry.PointCloud()

    # add x,y,z to o3d cloud
    pcd_t.point.positions = o3d.core.Tensor(points)

    # if rgb present, convert to o3d colors
    all_dims = list(las.point_format.dimension_names)[3:]
    if "red" in all_dims and "green" in all_dims and "blue" in all_dims:
        colors = np.vstack((las.red, las.green, las.blue)).transpose()
        pcd_t.point.colors = o3d.core.Tensor(colors)
        all_dims.remove("blue")
        all_dims.remove("green")
        all_dims.remove("red")

    # add other attributes
    attributes = all_dims

    for attr in attributes:
        # If only has single value, this is much faster
        if np.all(las[attr] == las[attr][0]):
            # Fill with the single value
            las_attr = np.full((len(las[attr]), 1), las[attr][0])
        else:
            # assumes only 1d.  Otherwise you need vstack which is slower
            las_attr = np.array(las[attr])[:, None]

        pcd_t.point[attr] = o3d.core.Tensor(las_attr)

    return pcd_t


las = laspy.read("path/to/file/data.laz")
pcd = laspy_to_o3d(las)
pcd # now in open3d format

You should probably break your questions about a web tool and rendering into a separate question(s). Check out https://plas.io/, it has some code for rendering files I think.

Upvotes: 0

Related Questions