Open3D
Open3D copied to clipboard
MemoryError and Segmentation Fault when visualizing textured mesh
Checklist
- [X] I have searched for similar issues.
- [X] For Python issues, I have tested with the latest development wheel.
- [X] I have checked the release documentation and the latest documentation (for
masterbranch).
Describe the issue
I tried to add texture to a mesh that has been loaded from a .obj file, but I get a MemoryError: std::bad_alloc error. Repeating o3d.visualization.draw_geometries([mesh]) eventually cause to Segmentation fault (core dumped) error.
Steps to reproduce the bug
import cv2
import open3d as o3d
print(o3d.__version__)
mesh = o3d.io.read_triangle_mesh('sample.obj')
image = cv2.imread('sample_texture.png')
mesh.textures = [o3d.geometry.Image(image)]
o3d.visualization.draw_geometries([mesh])
Error message
MemoryError Traceback (most recent call last) Input In [7], in <cell line: 1>() ----> 1 o3d.visualization.draw_geometries([mesh])
MemoryError: std::bad_alloc
Expected behavior
Visualize the mesh without any error
Open3D, Python and System information
- Operating system: Ubuntu 20.04
- Python version: Python 3.9.5
- Open3D version: 0.15.2
- System architecture: x86
- Is this a remote workstation?: no
- How did you install Open3D?: pip
Additional information
No response
I don't know why, but It avoids the error by enabling the post processing:
mesh = o3d.io.read_triangle_mesh('sample.obj', True)
I don't know why, but It avoids the error by enabling the post processing:
mesh = o3d.io.read_triangle_mesh('sample.obj', True)
when you enable post processing, open3d map textures automatically, so "mesh.textures = [o3d.geometry.Image(image)]" is not necessary.
and if you want to render texture by yourself, you have to set material map id.