isl-org / Open3D

Open3D: A Modern Library for 3D Data Processing
http://www.open3d.org
Other
11.44k stars 2.31k forks source link

MemoryError and Segmentation Fault when visualizing textured mesh #5458

Open mohamad-hasan-sohan-ajini opened 2 years ago

mohamad-hasan-sohan-ajini commented 2 years ago

Checklist

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

mohamad-hasan-sohan-ajini commented 2 years ago

I don't know why, but It avoids the error by enabling the post processing:

mesh = o3d.io.read_triangle_mesh('sample.obj', True)
Horizon-42 commented 2 years ago

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.

Horizon-42 commented 2 years ago

and if you want to render texture by yourself, you have to set material map id.