Keddrick Yue
Keddrick Yue

Reputation: 31

Load the same .obj file by using Open3D and Trimesh respectively leading to different number of vertices

To read the mesh file xxxxx.obj I use Open3D and Trimesh module respectively by these codes:

import open3d as o3d
import trimesh

mesh = o3d.io.read_triangle_mesh(meshfile)
print(mesh)
mesh_ = trimesh.load_mesh(meshfile)
print(mesh_)

output is

TriangleMesh with 224946 points and 74996 triangles.
<trimesh.Trimesh(vertices.shape=(37486, 3), faces.shape=(74996, 3))>

It seems open3d got 224946 points while Trimesh got 37486 points, what cause this problem?

I print out both their vertices and triangles

____mesh_vert____:
 [[-0.77349651 -0.17361518 -0.5339487 ]
 [-0.77405303 -0.17450994 -0.52660068]
 [-0.77472924 -0.17558702 -0.51311542]
 ...
 [ 0.85712222  0.03432839  0.45968683]
 [ 0.8533449   0.04001502  0.4399732 ]
 [ 0.85333683  0.04001284  0.44043044]]
____mesh_vertices____:
 [[-0.77714473 -0.16696896 -0.52666056]
 [-0.77481598 -0.16823091 -0.53799069]
 [-0.77349651 -0.17361517 -0.53394872]
 ...
 [ 0.85654795  0.03840274  0.44923028]
 [ 0.85598844  0.03371801  0.43383372]
 [ 0.85334492  0.04001502  0.43997321]]
____mesh_triangles____:
 [[     0      1      2]
 [     3      4      5]
 [     6      7      8]
 ...
 [224937 224938 224939]
 [224940 224941 224942]
 [224943 224944 224945]]
____mesh_faces____:
 [[    8     7     0]
 [    0     1     8]
 [    9     8     1]
 ...
 [37465 37466 37485]
 [37484 37485 37482]
 [37482 37481 37484]]

What cause the differences?

Upvotes: 3

Views: 1920

Answers (1)

Mathieson
Mathieson

Reputation: 1282

I'm investigating a similar issue right now. The vert count I get when opening with trimesh is larger than when opening with Houdini. It seems to be odd behaviour trimesh has with uvs.

I found the number of lines starting with "v " in the obj file equaled the number of vertices Houdini loaded.

I found the number of lines starting with "vt " in the obj file equaled the number of vertices trimesh loaded.

It seems trimesh creates additional vertices to store the data for these extra "vt " lines, which I understand store UV data.

This is pretty bad because simply opening said obj file and saving it back out, without any modifications, using trimesh will change the vertex count for the mesh in DCCs. The extra vertices is created for the "vt " lines became additional "v " lines, in my testing.

Upvotes: 1

Related Questions