简体   繁体   English

使用 scikit-fmm 或 gdist 在 3d 三角形网格上测地距离

[英]geodesic distance on 3d triangular mesh using scikit-fmm or gdist

I'm trying to evaluate a geodesic distance matrix on the TOSCA dataset.我正在尝试评估 TOSCA 数据集上的测地线距离矩阵。 eg the following 3d mesh-例如下面的 3d 网格-
在此处输入图像描述

I've tried using two python implementations.我试过使用两个 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.第一个是scikit-fmm ,它似乎根本不适用于 3d 结构(我说的对吗?)因此不适合这项任务。
  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.另一个是gdist包,不幸的是,它适用于他们提供的玩具示例,但不适用于我的网格,它只有 10,000 个面和 5000 个顶点。
    When using the gdist library I have the following error:使用 gdist 库时出现以下错误:

     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)

Is there another solution?还有其他解决方案吗? Am I using gdist or scikit-fmm the wrong way?我是否以错误的方式使用 gdist 或 scikit-fmm?

Another solution would be to use MeshLib library with python interface.另一种解决方案是使用带有 python 接口的MeshLib库。 After installation via pip :通过pip安装后:

import meshlib.mrmeshpy as mr

Load a mesh from TOSCA dataset in OFF format:从 TOSCA 数据集中以 OFF 格式加载网格:

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

I found the meshes from this dataset here: https://vision.in.tum.de/data/datasets/partial我在这里找到了这个数据集中的网格: https ://vision.in.tum.de/data/datasets/partial

Then you will be interested in two function as follows.然后您会对以下两个功能感兴趣。

  1. mr.computeSurfaceDistances(mesh, surfacePoint) , which returns the distance from given surface point to every vertex in the mesh computed by Fast Marching method . mr.computeSurfaceDistances(mesh, surfacePoint) ,它返回从给定表面点到网格中由Fast Marching 方法计算的每个顶点的距离。 For example, here are computed distances are visualized by color and isolines:例如,这里计算的距离通过颜色和等值线可视化:

在 MeshLib 中计算的距离等值线

  1. mr.computeGeodesicPath(mesh, surfacePoint1, surfacePoint2) , which computes exact geodesic path between two surface points. mr.computeGeodesicPath(mesh, surfacePoint1, surfacePoint2) ,计算两个表面点之间的精确测地线路径。 The computation starts from a path approximation given by Dijkstra or Fast Marching method and then it is iteratively reduced in length until convergence.计算从 Dijkstra 或 Fast Marching 方法给出的路径近似开始,然后迭代减少长度直到收敛。 Geodesic path example between two points:两点之间的测地线路径示例:

MeshLib 中的测地线路径

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM