使用Scikit-fmm或gdist计算3D三角网格上的测地线距离

5
我正在尝试在TOSCA数据集上评估测地线距离矩阵。例如,以下3D网格-
enter image description here 我尝试使用两个Python实现。
  1. The first one is the scikit-fmm, which does not seems to work on 3d structures at all (am I right?) hence not suitable to the task.
  2. The other one is the gdist package, which Unfortunatlly works on the toy example they provide, but does not work on my mesh, which is only 10,000 faces and 5000 vertices.
    When using the gdist library I have the following error:

    Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)
    --------CODE SNIPPET----------
    c = sio.loadmat('raw_data/TOSCA/cat0.mat')
    c = c['surface'][0][0]
    X = c[0]
    Y = c[1]
    Z = c[2]
    TRIV = c[3].astype(np.int32)
    vertices = np.array(zip(X, Y, Z)).astype(np.float64)
    vertices = np.reshape(vertices, (vertices.shape[0], 3))
    src = np.array([1], dtype=np.int32)
    trg = np.array([2], dtype=np.int32)
    
    np.random.shuffle(TRIV)
    
    a = gdist.compute_gdist(vertices,TRIV[:5000], source_indices = src, target_indices = trg)
    

是否有其他解决方案?我是在错误地使用gdist或scikit-fmm吗?


根据我的经验,在尝试使用过多内存时,我只遇到过 SIGSEGV 错误。你能将任务分解吗? - SyntaxVoid
1
很遗憾,不能隐藏更多的面孔,因为这会使答案无关紧要,并且具有5000个面的网格被认为是较小的,我知道这些计算可以更大。 - DsCpp
1个回答

2

另一种解决方案是使用带有Python接口的MeshLib库。在通过pip安装后:

import meshlib.mrmeshpy as mr

从TOSCA数据集中以OFF格式加载网格:

mesh = mr.loadMesh("centaur1.off")

我在这里找到了数据集中的网格:https://vision.in.tum.de/data/datasets/partial 接下来,您可能会对以下两个函数感兴趣:
1. mr.computeSurfaceDistances(mesh, surfacePoint),该函数使用快速行进法计算给定表面点到网格中每个顶点的距离。例如,下图展示了通过颜色和等值线可视化的计算距离:
Isolines of distances computed in MeshLib 2. mr.computeGeodesicPath(mesh, surfacePoint1, surfacePoint2),该函数计算两个表面点之间的精确测地路径。该计算从由Dijkstra或Fast Marching方法给出的路径近似开始,然后迭代缩短路径长度直至收敛。下图显示了两个点之间的测地路径示例:
Geodesic path in MeshLib

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接