【问题标题】:How to select an array of vertices in pymeshlab?如何在pymeshlab中选择顶点数组?
【发布时间】:2021-09-25 17:45:14
【问题描述】:

我想从网格中删除一些存储在 NumPy 数组中的顶点。如何根据顶点索引或坐标在 pymeshlab 中选择这些顶点?谢谢!

import pymeshlab
from scipy.spatial import KDTree

def remove_background(subdir, ms):
    # load joint points
    joint_arr = load_joint_points(subdir)

    # get a reference to the current mesh
    m = ms.current_mesh()

    # get numpy arrays of vertices of the current mesh
    vertex_array_matrix = m.vertex_matrix()
    print(f'total # of vertices: {m.vertex_number()}')

    # create a KD tree of the joint points
    tree = KDTree(joint_arr)

    selected_vertices = []

    for vertex in vertex_array_matrix:
        # if the closest joint pt is farther than 500mm from the vertex, add the vertex to list
        dd, ii = tree.query(vertex, k=1)
        if(dd > 500):
            selected_vertices.append(vertex)

    print(f"delete {len(selected_vertices)} vertices")
    
    #how to select 'selected vertices' in pymeshlab?

    ms.delete_selected_vertices()

【问题讨论】:

  • 请提供最少的可重复样本。
  • 嗨,Pouya,我已经包含了我的代码。我非常感谢您对此的任何反馈或想法。

标签: python meshlab pymeshlab


【解决方案1】:

是的!您可以使用 conditional selection filter 的索引有条件地选择顶点

import pymeshlab as ml
ms = ml.MeshSet()
# just create a simple mesh for example
ms.sphere(subdiv=0)
# select the vertex with index 0
ms.conditional_vertex_selection(condselect="vi==0") 
# delete selected stuff
ms.delete_selected_vertices() 

更好的是,您可以在 pymeshlab 中完成所有背景移除。 如果您有两个网格/点云 AB 并且您想从 B 中移除所有靠近 B 的顶点em>A 小于给定阈值,您可以只加载两个网格,使用 Hausdorff Distance filter 将存储到 A 的每个顶点的“质量”中B最近顶点的距离;那么这次你可以通过质量测试再次使用条件选择过滤器。

【讨论】:

  • 非常感谢!这正是我正在寻找的。​​span>
猜你喜欢
  • 2023-03-20
  • 2021-04-01
  • 2021-12-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多