Skip to content
New issue

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

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

Already on GitHub? # to your account

Loading OBJ file from ShapeNet fails #13

Open
HanG-94 opened this issue Mar 29, 2023 · 3 comments
Open

Loading OBJ file from ShapeNet fails #13

HanG-94 opened this issue Mar 29, 2023 · 3 comments

Comments

@HanG-94
Copy link

HanG-94 commented Mar 29, 2023

Hi simple-3dviz Team,
when i try to load .obj file from ShapeNet using Mesh.from_file("model_normalized.obj") then gives following error:

File ~/miniconda3/lib/python3.10/site-packages/simple_3dviz/io/mesh.py:147, in ObjMeshReader.read..extract_uv(face)
146 def extract_uv(face):
--> 147 return int(face.split("/")[1])-1

ValueError: invalid literal for int() with base 10: ''

The version of simple-3dviz is 0.7.0. The .obj file i list here:
model_normalized.zip

could you please help me out?

Regards,
Han Gao

@HanG-94
Copy link
Author

HanG-94 commented Mar 30, 2023

Dear simple-3dviz Team,

i think the obj from ShapeNet.v2 consists of multiple models, which cannot be loaded by Mesh.from_file(). A possible workaround could be using the trimesh.load(file, force='mesh').

Regards,
Han

@paschalidoud
Copy link
Collaborator

Hi @HanG-94,

Thanks a lot for using our library. Do you mind sharing the obj file you that causes the ValueError?

Best,
Despi

@GiulioFede
Copy link

GiulioFede commented Oct 17, 2024

Go to the lib file: simple_3dviz/io/mesh.py and modify those methods of class ObjMeshReader(MeshReader):

def read(self, filename):
    def extract_vertex(face):
        **if "//" in face:
            return int(face.split("//")[0])-1**
        return int(face.split("/")[0])-1

    def extract_normal(face):
        **if "//" in face:
            return int(face.split("//")[2])-1**
        return int(face.split("/")[2])-1

    def extract_uv(face):
        **if "//" in face:
            return int(face.split("//")[1])-1**
        return int(face.split("/")[1])-1

in ** ** the new parts.

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

No branches or pull requests

3 participants