Open3D 生成多个球形点云

一、概述

        使用 Open3D 创建一个三角网格的球体,并从中均匀采样点生成点云,同时可以指定球体的半径和中心位置。生成 5 个不同大小和位置的圆球形点云,并将它们合并成一个点云以进行显示。

二、代码实现

import open3d as o3d
import numpy as np

def create_sphere(radius=1, center=[0, 0, 0], resolution=20):
    mesh_sphere = o3d.geometry.TriangleMesh.create_sphere(radius=radius, resolution=resolution)
    mesh_sphere.translate(center)
    pcd = mesh_sphere.sample_points_uniformly(number_of_points=2000)
    return pcd

# 定义球体的半径和中心位置
radii = [1, 0.8, 0.6, 0.9, 1.2]
centers = [[0, 0, 0], [2, 2, 0], [-2, -2, 0], [2, -2, 0], [-2, 2, 0]]

# 创建点云列表
point_clouds = [create_sphere(radius=r, center=c) for r, c in zip(radii, centers)]

# 合并所有点云
combined_pcd = point_clouds[0]
for pcd in point_clouds[1:]:
    combined_pcd += pcd

o3d.io.write_point_cloud('3dballs.pcd',combined_pcd)
# 显示点云
o3d.visualization.draw_geometries([combined_pcd])

三、实现效果

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值