如何创建一个适合于网格或点云表面的函数?

huangapple go评论69阅读模式
英文:

How can I make a function which fits the surface of a mesh or point cloud

问题

我对找到一种用函数描述网格而不是三角形的方法非常感兴趣。这是因为在我正在构建的应用程序中,拥有连续的点和法线会非常有益。然而,我还没有弄清楚它是如何工作的。

我要描述的网格在每次应用程序重新启动时都会因直接从实时捕获的深度图像中重建而在形状上有所变化,但网格的整体形状将大致相同。

这是该网格的示例,以便更容易理解:
如何创建一个适合于网格或点云表面的函数?

我已经研究了scipy和numpy的函数,但在所有情况下,似乎我需要提供x和y数据,然后根据它们获得某个z值,但由于我已经有了x、y和z值,我只想进行某种曲面拟合估计。

任何帮助将不胜感激。

编辑:
在@stef的帮助下,我找到了CloughTocher2DInterpolator函数,并使用它创建了这个:

如何创建一个适合于网格或点云表面的函数?

我不确定这是否是一个良好的拟合。因此,如果有人有一些建议,请告诉我。我用于执行此操作的代码如下:

import open3d as o3d
import numpy as np
from scipy.interpolate import CloughTocher2DInterpolator
import matplotlib.pyplot as plt

mesh = o3d.io.read_triangle_mesh("meshPath")
pcd = mesh.sample_points_uniformly(number_of_points=2500)

o3d.visualization.draw_geometries([pcd])

points = np.asarray(pcd.points)

x = points[:, 0]
y = points[:, 1]
z = points[:, 2]

X = np.linspace(min(x), max(x))
Y = np.linspace(min(y), max(y))
X, Y = np.meshgrid(X, Y)  # 用于插值的2D网格
interp = CloughTocher2DInterpolator(list(zip(x, y)), z, fill_value=-1.35)
Z = interp(X, Y)

fig = plt.figure()
ax = plt.axes(projection='3d')
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap='viridis', edgecolor='none')
ax.set_title('曲面')

ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')
plt.show()

我可以绘制包括线框、等高线图等在内的曲面,它们似乎都看起来不错,除了左侧的尖峰。

英文:

I am very interested in figuring out a way to describe a mesh with a function instead of triangles. This is because having a continues amount of points and normals would be very beneficial for the application I am building. However I haven't been able to figure out how it works.
The mesh I have to describe varies in shape each time the application is restarted as it is reconstructed directly from live captured depth images, however the overall shape of the mesh will be approximately the same.
This is the mesh of the mesh in case that makes it easier:
如何创建一个适合于网格或点云表面的函数?
I have looked into scipy and numpy function but in all cases it seems like I provide x and y data and then I get some z value accordingly, but since I already have x, y and z values I just want to make some sort of surface fit estimations.
Any help would be much appreciated.

EDIT:
With the help from @stef I found the function CloughTocher2DInterpolator, and with that I created this:

如何创建一个适合于网格或点云表面的函数?

I¨m not sure if this is a good fit or not. So if someone have some suggestions please let me know. The code I use to do this was the following:

import open3d as o3d
import numpy as np
from scipy.interpolate import CloughTocher2DInterpolator
import matplotlib.pyplot as plt

mesh = o3d.io.read_triangle_mesh("../meshPath")
pcd = mesh.sample_points_uniformly(number_of_points=2500)


o3d.visualization.draw_geometries([pcd])

points = np.asarray(pcd.points)


x = points[:,0]
y = points[:,1]
z = points[:,2]

X = np.linspace(min(x), max(x))
Y = np.linspace(min(y), max(y))
X, Y = np.meshgrid(X, Y)  # 2D grid for interpolation
interp = CloughTocher2DInterpolator(list(zip(x, y)), z, fill_value=-1.35)
Z = interp(X, Y)
#value = interp.__call__([1, 1])
fig = plt.figure()
ax = plt.axes(projection='3d')
#ax.contour3D(X, Y, Z, 75, cmap='prism')
#ax.plot_trisurf(x, y, z, cmap='viridis', edgecolor='none')
#ax.plot_wireframe(X, Y, Z, color='black')
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap='viridis', edgecolor='none')
ax.set_title('surface')


ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')
plt.show()

I can plot the surface with wireframes, contour plot and so on and they all seem to look good, beside the spikes on the left side.

答案1

得分: 1

你可以尝试使用 FindSurface Web Demo.URL

FindSurface Web Demo.PNG

点数据文件必须是XYZ或OBJ格式之一。

如果您的对象表面是人体,我建议您使用以下参数值。

Input point parameter values.PNG

  • 测量精度:5-10毫米
  • 平均距离:10-20毫米
  • 触摸半径:100-150毫米。

然后,

  1. 选择球体的模型类型
  2. 单击球体表面区域中的一个点。

FindSurface运行库的工作原理在 FindSurface runtime library.URL 中有详细说明。

我在CurvSurf, Inc.工作,开发FindSurface运行库。

FindSurface运行库是CurvSurf, Inc.的软件产品,位于韩国。此库的所有权完全归CurvSurf, Inc.所有,任何人都可以将其用于非商业目的。有关库的商业使用,请联系'support at curvsurf dot com'。

英文:

You may like to try FindSurface Web Demo.URL.

FindSurface Web Demo.PNG

The point data file must be either of XYZ or OBJ format.

If your object surface is of human body, I recommend you the following parameter values.

Input point parameter values.PNG

  • Measurement Accuracy: 5-10 mm
  • Mean Distance: 10-20 mm
  • Touch Radius: 100-150 mm.

Then,

  1. Select the model type of sphere
  2. Click a point in the spherical object surface area.

How does work the FindSurface runtime library is explained at FindSurface runtime library.URL.

I work for CurvSurf, Inc. developing the FindSurface runtime library.

The FindSurface runtime library is a software product of CurvSurf, Inc., South Korea. This library's ownership is solely on CurvSurf, Inc. and anyone can use it for non-commercial purposes. Contact to 'support at curvsurf dot com' for commercial use of the library.

huangapple
  • 本文由 发表于 2023年2月14日 19:42:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/75447335.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定