GithubHelp home page GithubHelp logo

Comments (2)

amiltonwong avatar amiltonwong commented on June 19, 2024 1

@Szy-Young , Thanks a lot, I'll try it.

from ogc.

Szy-Young avatar Szy-Young commented on June 19, 2024

Hi @amiltonwong

You can use the following code for a quick visualization with Open3D:

# pc: (N, 3) numpy array
# segm: (N,) numpy array

import open3d as o3d
from utils.visual_util import build_pointcloud

pcds = [build_pointcloud(pc, segm)]
o3d.visualization.draw_geometries(pcds)

For the visualization effects in our paper and video demo, you can first use the following code to convert point clouds into meshes of spheres:

# pc: (N, 3) numpy array
# segm: (N,) numpy array

import open3d as o3d

def pc_segm_to_sphere(pc, segm=None, radius = 0.01, resolution=10, with_background=False, default_color=COLORGRAY2):
    """
    Visualize point cloud as mesh balls. The color denotes hard segmentation.
    :param pc: (N, 3)
    :param segm: (N,)
    """
    assert pc.shape[1] == 3 and len(pc.shape) == 2, f"Point cloud is of size {pc.shape} and cannot be displayed!"
    n_point = pc.shape[0]
    if with_background:
        colors = np.concatenate((COLOR20[-1:], COLOR20[:-1]), axis=0)
    else:
        colors = COLOR20

    meshes = []
    for pid in range(n_point):
        mesh = o3d.geometry.TriangleMesh.create_sphere(radius=radius, resolution=resolution)
        if segm is not None:
            mesh.paint_uniform_color(colors[segm[pid] % colors.shape[0]] / 255.)
        else:
            mesh.paint_uniform_color(default_color / 255.)
        mesh.translate(pc[pid])
        meshes.append(mesh)

    # Merge
    mesh = meshes[0]
    for i in range(1, len(meshes)):
        mesh += meshes[i]
    return mesh

mesh = pc_segm_to_sphere(pc, segm)
save_file = ...
o3d.io.write_triangle_mesh(save_file, mesh)

Then you can render the mesh models with softwares like KeyShot (our choice), Blender, etc.

from ogc.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.