Open3D icon indicating copy to clipboard operation
Open3D copied to clipboard

Error loading ShapeNet meshes with texture

Open janbechtold opened this issue 4 years ago • 5 comments

Describe the bug When loading specific ShapeNet meshes with Open3D > 0.11, the process ends after printing 'Not a JPEG file: starts with 0x89 0x50'. In contrast, Open3D version 0.8.0 with python 3.7.9 returns a mesh.

To Reproduce Steps to reproduce the behavior: From within your ShapeNetCore.v2 directory...

  1. cd '02801938/d9f0f7cff584b60d826faebfb5cddf3c/models'
  2. source activate yourcondaenv
  3. python

import open3d as o3d o3d.io.read_triangle_mesh('model_normalized.obj')

  1. See error: Not a JPEG file: starts with 0x89 0x50

(same for this model: 03467517/2cbc0faddf227502bbc745a3524d966b/models)

Expected behavior

  1. A mesh is returned automatically without texture, or
  2. An option to not load the texture, or
  3. A way to catch this in python

Environment (please complete the following information):

  • Operating system: RHEL8
  • Python version: 3.8
  • Open3D version: 0.13.0
  • Is this remote workstation?: yes
  • How did you install Open3D?: conda

janbechtold avatar Dec 01 '21 13:12 janbechtold

In fact, I also meet the same bug when I used the API read_triangle_mesh in the Shapenet-v1.

wangyePHD avatar Mar 01 '22 02:03 wangyePHD

And I think that maybe the .obj file has some problem.

wangyePHD avatar Mar 01 '22 02:03 wangyePHD

The same issue with 02691156/de45798ef57fe2d131b4f9e586a6d334

Steven-xzr avatar Jun 27 '22 09:06 Steven-xzr

How can we solve it? I simply removed that particular data..

juc023 avatar Jul 03 '22 02:07 juc023

It seems the error is with the texture files. If you put the .obj file in a separate folder, it loads in Open3D correctly.

If you need the textures, take a look at this answer: https://blender.stackexchange.com/questions/89010/materials-not-applied-after-importing-obj-shapenet/188192#188192 . You can convert the buggy .obj model from ShapeNet to a .glb model using https://github.com/CesiumGS/obj2gltf.

Saafke avatar Aug 02 '22 08:08 Saafke

The same issue with 02691156/31b201b7346e6cd15e9e2656aff7dd5b

yjang2 avatar Apr 27 '23 15:04 yjang2

For more context on the ShapeNet bug (Stanford url download): it comes from png files having jpg extensions, nothing wrong with the obj file by itself. As mentioned by @Saafke, gets solved by moving to different directory.

In terms of possible fix to o3d: I am able to load the images with matplotlib though. It might be that o3d uses file extensions rather than first bytes to determine file type.

tomas-aftalion avatar Aug 17 '23 18:08 tomas-aftalion

@tomas-aftalion yeah, you are right.

https://gist.github.com/leommoore/f9e57ba2aa4bf197ebc5

0x89 0x50 is png magic number.

And open3d does read based on file extension in the name and not using magic number.

https://github.com/isl-org/Open3D/blob/c7718fd626d2f446bbbf40fd552ffd424e66d7a0/cpp/open3d/io/ImageIO.cpp#L23

saurabheights avatar Aug 18 '23 00:08 saurabheights