英文:
open3d | How to calculate the volume of a mesh created by point cloud?
问题
使用 'open3d.geometry.TriangleMesh.create_from_point_cloud_alpha_shape' 函数创建了一个网格,并想要计算其体积。但是出现了以下 RuntimeError 错误:
[Open3D WARNING] [CreateFromPointCloudAlphaShape] invalid tetra in TetraMesh
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
Input In [27], in <cell line: 7>()
3 point_cloud.points = open3d.utility.Vector3dVector(data_all)
5 tri_mesh = open3d.geometry.TriangleMesh.create_from_point_cloud_alpha_shape(point_cloud, alpha=10)
----> 7 v = open3d.geometry.TriangleMesh.get_volume(tri_mesh)
8 print(v)
RuntimeError: [Open3D Error] (double open3d::geometry::TriangleMesh::GetVolume() const) /Users/runner/work/Open3D/Open3D/cpp/open3d/geometry/TriangleMesh.cpp:1220: 网格不是完全封闭的,无法计算体积。
我在网上搜索(https://github.com/isl-org/Open3D/pull/3201)并发现警告消息(invalid tetra in TetraMesh)是一个常见问题,原因是一些点位于网格内部而不在表面。因此,我通过计算每个点到表面的距离来排除所有不在表面的点。
然后,我再次使用 'open3d.geometry.TriangleMesh.create_from_point_cloud_alpha_shape' 函数重新创建网格。但是仍然出现了相同的问题,网格仍然不是完全封闭的。
是否有方法可以解决这个问题并计算体积?
谢谢!
英文:
I create a mesh by using 'open3d.geometry.TriangleMesh.create_from_point_cloud_alpha_shape' function and wanted to calculate the volume of it. But a RuntimeError occurs as the following shows:
[Open3D WARNING] [CreateFromPointCloudAlphaShape] invalid tetra in TetraMesh
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
Input In [27], in <cell line: 7>()
3 point_cloud.points = open3d.utility.Vector3dVector(data_all)
5 tri_mesh = open3d.geometry.TriangleMesh.create_from_point_cloud_alpha_shape(point_cloud, alpha=10)
----> 7 v = open3d.geometry.TriangleMesh.get_volume(tri_mesh)
8 print(v)
RuntimeError: [Open3D Error] (double open3d::geometry::TriangleMesh::GetVolume() const) /Users/runner/work/Open3D/Open3D/cpp/open3d/geometry/TriangleMesh.cpp:1220: The mesh is not watertight, and the volume cannot be computed.
I searched online (https://github.com/isl-org/Open3D/pull/3201) and found that the warning message (invalid tetra in TetraMesh) is a common problem and the reason is that some points are inside the mesh and not in the surface. Therefore, I exclude all the points that are not in the surface by calculating each point's distance to the surface.
Then, I recreate the mesh by using 'open3d.geometry.TriangleMesh.create_from_point_cloud_alpha_shape' function. The same issue occurs and the mesh is still not watertight.
Is there any method to solve this problem and calculate the volume?
Thanks!
答案1
得分: 1
为了计算体积,您需要一个无漏洞的网格,这意味着它不能有任何开口。这不是Alpha形状算法能够保证的事情;如果您选择较小的Alpha值,最终它将只创建微小的岛屿或孤立的三角形。
教程中有关于不同Alpha值的示例:
http://www.open3d.org/html/tutorial/Advanced/surface_reconstruction.html
您可以检查是否成功使用tri_mesh.is_watertight()
。
但这里的核心问题实际上是如何使网格密封,这在这个问题中已经被提问并回答了。
也许对于您的情况来说,选择一个较大的alpha
已经足够了,或者也许您可以通过使用替代算法如create_from_point_cloud_poisson
(应该能够保证密封,如果形状主要是凸的话,体积会被低估)或create_from_point_cloud_ball_pivoting
来更好地满足您的需求。
您应该绘制您的几何图形和点云以进行视觉检查,并比较每种方法的体积。
英文:
In order to compute the volume you need a watertight mesh, which means it must have no openings. This isn't something the alpha shape algorithm guarantees; f you pick a smaller alpha, eventually it will just create tiny islands or isolated triangles.
The tutorial has examples of what happens with different alphas:
http://www.open3d.org/html/tutorial/Advanced/surface_reconstruction.html
You can check whether you had success with tri_mesh.is_watertight()
.
But the core problem here is really how to make the mesh watertight, which is asked and answered in this question.
Maybe picking a larger alpha
is good enough for your case, or maybe you would be better served by an alternative algorithm like create_from_point_cloud_poisson
(which should be guaranteed watertight, volume would be underestimated if the shape is mostly convex) or create_from_point_cloud_ball_pivoting
.
You should plot your geometries and point cloud for visual inspection, and also compare the volume from each method.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论