在 Python 3 中使用行进立方体进行点云三角测量 [英] Point Cloud triangulation using marching-cubes in Python 3

查看:279
本文介绍了在 Python 3 中使用行进立方体进行点云三角测量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究 3D 重建系统,并希望使用 Python 3 从注册点云数据生成三角形网格.我的对象不是凸面,因此行进立方体算法似乎是解决方案.

I'm working on a 3D reconstruction system and want to generate a triangular mesh from the registered point cloud data using Python 3. My objects are not convex, so the marching cubes algorithm seems to be the solution.

我更喜欢使用这种方法的现有实现,所以我尝试了 scikit-imageOpen3d但是这两个 API 都不接受原始点云作为输入(请注意,我不是这些库的专家).我尝试转换我的数据失败了,而且我的想法已经用完了,因为文档没有阐明函数的输入格式.

I prefer to use an existing implementation of such method, so I tried scikit-image and Open3d but both the APIs do not accept raw point clouds as input (note that I'm not expert of those libraries). My attempts to convert my data failed and I'm running out of ideas since the documentation does not clarify the input format of the functions.

这些是我想要的片段,其中 pcd_to_volume 是我需要的.

These are my desired snippets where pcd_to_volume is what I need.

scikit-image

import numpy as np
from skimage.measure import marching_cubes_lewiner

N = 10000
pcd = np.random.rand(N,3)

def pcd_to_volume(pcd, voxel_size):
    #TODO

volume = pcd_to_volume(pcd, voxel_size=0.05)

verts, faces, normals, values = marching_cubes_lewiner(volume, 0)

open3d

import numpy as np
import open3d

N = 10000
pcd = np.random.rand(N,3)

def pcd_to_volume(pcd, voxel_size):
    #TODO

volume = pcd_to_volume(pcd, voxel_size=0.05)

mesh = volume.extract_triangle_mesh()

我找不到正确编写 pcd_to_volume 函数的方法.我不喜欢图书馆而不是另一个,所以这两种解决方案对我来说都很好.

I'm not able to find a way to properly write the pcd_to_volume function. I do not prefer a library over the other, so both the solutions are fine to me.

您对正确转换我的数据有什么建议吗?点云是一个 Nx3 矩阵,其中 dtype=float.

Do you have any suggestions to properly convert my data? A point cloud is a Nx3 matrix where dtype=float.

您知道另一种适用于原始点云数据的 [行进立方体算法] 实现吗?我更喜欢像 scikit 和 open3d 这样的库,但我也会考虑 github 项目.

Do you know another implementation [of the marching cube algorithm] that works on raw point cloud data? I would prefer libraries like scikit and open3d, but I will also take into account github projects.

推荐答案

你知道另一种适用于原始点云数据的[行进立方体算法]实现吗?

Do you know another implementation [of the marching cube algorithm] that works on raw point cloud data?

Hoppe 的论文 从无组织点重建表面 可能包含您需要的信息,它是 开源.

Hoppe's paper Surface reconstruction from unorganized points might contain the information you needed and it's open sourced.

最新的 Open3D 似乎包含了表面重建算法,例如 alphaShape, ballPivoting泊松重建.

And latest Open3D seems to be containing surface reconstruction algorithms like alphaShape, ballPivoting and PoissonReconstruction.

据我所知,marching cubes 通常用于提取多边形网格来自三维离散标量场的等值面(这就是您所说的体积).该算法不适用于原始点云数据.

From what I know, marching cubes is usually used for extracting a polygonal mesh of an isosurface from a three-dimensional discrete scalar field (that's what you mean by volume). The algorithm does not work on raw point cloud data.

Hoppe 的算法首先生成一个带符号的距离函数场(一个 SDF 体积),然后将其传递给行进立方体.这可以看作是对您的一种实现pcd_to_volume,而且它不是唯一的方法!

Hoppe's algorithm works by first generating a signed distance function field (a SDF volume), and then passing it to marching cubes. This can be seen as an implementation to you pcd_to_volume and it's not the only way!

如果只有原始点云,那么情况就会有点受限.如您所见,泊松重建筛选泊松重建 算法都以自己的方式实现pcd_to_volume(它们高度相关).但是,它们需要额外的点法线信息,并且法线必须一致定向.(为了一致的方向,你可以阅读这个问题).

If the raw point cloud is all you have, then the situation is a little bit constrained. As you might see, the Poisson reconstruction and Screened Poisson reconstruction algorithm both implement pcd_to_volume in their own way (they are highly related). However, they needs additional point normal information, and the normals have to be consistently oriented. (For consistent orientation you can read this question).

虽然一些基于 Delaunay 的算法(他们不使用行进立方体) 像 alphaShape 和 this 可能不需要点法线作为输入,因为具有复杂拓扑结构的曲面,由于方向问题很难得到满意的结果.而图切割方法可以使用可见性信息来解决这个问题.

While some Delaunay based algorithm (they do not use marching cubes) like alphaShape and this may not need point normals as input, for surfaces with complex topology, it's hard to get a satisfactory result due to orientation problem. And the graph cuts method can use visibility information to solve that.

话虽如此,如果您的数据来自深度图像,您通常会有可见性信息.您可以使用 TSDF 构建良好的表面网格.Open3D 已经已经实现了.

Having said that, if your data comes from depth images, you will usually have visibility information. And you can use TSDF to build a good surface mesh. Open3D have already implemented that.

这篇关于在 Python 3 中使用行进立方体进行点云三角测量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆