Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyErrors in by_vertex_clusters #24

Open
Skylion007 opened this issue Jan 24, 2022 · 8 comments
Open

KeyErrors in by_vertex_clusters #24

Skylion007 opened this issue Jan 24, 2022 · 8 comments

Comments

@Skylion007
Copy link
Contributor

I noticed that sk.skeletonize.by_vertex_clusters can generate KeyErrors when the sampling_dist at certain values like 0.01. Changing the sampling distance to a value that can be represented better by floating point works fine though.

Example Traceback:

Traceback (most recent call last):
  File "skeletor_data/contract_mesh.py", line 12, in <module>
    skele = sk.skeletonize.by_vertex_clusters(c_mesh, sampling_dist=0.01)
  File "skeletor/skeletonize/vertex_cluster.py", line 193, in by_vertex_clusters
    vertex_to_node_map = np.array([new_ids[n] for n in vertex_to_node_map])
  File "skeletor/skeletonize/vertex_cluster.py", line 193, in <listcomp>
    vertex_to_node_map = np.array([new_ids[n] for n in vertex_to_node_map])
KeyError: 413
@schlegelp
Copy link
Collaborator

Sorry for missing this issue until now. I can't reproduce the issue. Could you perhaps share your c_mesh?

@Skylion007
Copy link
Contributor Author

@schlegelp
Here is a reproducer:

import sys

import trimesh as tm
import skeletor as sk
mesh_filename = sys.argv[1]
tm_mesh = tm.load(mesh_filename)
tm_mesh.show()
tm_mesh = sk.pre.simplify(tm_mesh, ratio=0.1)
sk.pre.fix_mesh(tm_mesh, remove_disconnected=5, inplace=True)
c_mesh = sk.pre.contract(tm_mesh, epsilon=0.1)
c_mesh.show()
print("Contracted")
skele = sk.skeletonize.by_vertex_clusters(c_mesh, sampling_dist=0.175)
skele.mesh = tm_mesh
sk.post.clean_up(skele)
sk.post.radii(skele, method='knn')
skele.show(mesh=True)

On the Stanford Armadillo Mesh: http://graphics.stanford.edu/pub/3Dscanrep/armadillo/Armadillo.ply.gz

@Skylion007
Copy link
Contributor Author

Skylion007 commented Jun 7, 2022

Traceback:

Traceback (most recent call last):
  File "skele_mesh.py", line 12, in <module>
    skele = sk.skeletonize.by_vertex_clusters(c_mesh, sampling_dist=0.175)
  File "/Users/agokaslan/venvs/ai_habitat_sys_py3/lib/python3.8/site-packages/skeletor/skeletonize/vertex_cluster.py", line 191, in by_vertex_clusters
    vertex_to_node_map = np.array([new_ids[n] for n in vertex_to_node_map])
  File "/Users/agokaslan/venvs/ai_habitat_sys_py3/lib/python3.8/site-packages/skeletor/skeletonize/vertex_cluster.py", line 191, in <listcomp>
    vertex_to_node_map = np.array([new_ids[n] for n in vertex_to_node_map])
KeyError: 2925

@Skylion007
Copy link
Contributor Author

Tag @schlegelp

@schlegelp
Copy link
Collaborator

Will look into into - a bit swamped at the moment.

@schlegelp
Copy link
Collaborator

Strangely, this works just fine for me. You could perhaps share the c_mesh you feed into the skeletonization?

On a side note: you might want to use the inplace=True parameter when you run sk.post.clean_up(skele).

@Sakura0124
Copy link

Have you solved this problem? @Skylion007 @schlegelp

@schlegelp
Copy link
Collaborator

I haven't been able to reproduce the issue. Are you experiencing the same problem? If so, could you share a reprex?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants