Dragging a 3D object as .obj file (Wavefront .obj file) to MeshLab or any other 3D graphics tells you the exact total number of faces and total number of vertices the model has. Vertices could be triangular or polygonal.
Is there any way to calculate accurately these 2 numbers programmatically? by reading the Obj file and outputting these numbers. Now some tools like MeshLab output a comment section in the obj file produced, saying how many faces, vertices etc... other tools don't do that.
I tried to count the number of 'v' and 'f' but that does not always give accurate results when compared to MeshLab results. What about vn and vt? sorry I am not that knowledgeable in obj file structure and what these letters really mean.
Any way of doing that in Python? It would be cool if there is a library that can do that and output also resolutions of textures used?
Thanks for any suggestions
This code shows the same numbers as Autodesk Maya
with open('test.obj') as f:
lines = f.readlines()
vertices = len([line for line in lines if line.startswith('v ')])
faces = len([line for line in lines if line.startswith('f ')])