isl-org / isl-org/Open3D

Cannot disable renderer.render_to_image() console output when using OffscreenRenderer

Open
#7,328 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C++
Stars
14k
Forks
2.6k
Avg merge
5d 18h
Merged PRs (30d)
6

Description

### Checklist

- [x] I have searched for [similar issues](https://github.com/isl-org/Open3D/issues).
- [x] For Python issues, I have tested with the [latest development wheel](https://www.open3d.org/docs/latest/getting_started.html#development-version-pip).
- [x] I have checked the [release documentation](https://www.open3d.org/docs/release/) and the [latest documentation](https://www.open3d.org/docs/latest/) (for `main` branch).

### Describe the issue

I try to render a scene using _o3d.visualization.rendering.OffscreenRenderer_

But whenever I call _renderer.render_to_image()_ I get this output

```
[Open3D INFO] EGL headless mode enabled.
FEngine (64 bits) created at 0x2fa3d850 (threading is enabled)
EGL(1.5)
OpenGL(4.6)
```

I tried to set:

```
o3d.utility.set_verbosity_level(o3d.utility.VerbosityLevel.Error)
```

Which disabled the [Open3D INFO] EGL headless mode enabled. line

I even tried setting

```
sys.stdout = open(os.devnull, 'w')
sys.stderr = open(os.devnull, 'w')
```

and tried to use

```
output = open(os.devnull, 'w')

with redirect_stdout(output), redirect_stderr(output):
renderer.render_to_image()
```

Which both still lead to the same output

### Steps to reproduce the bug

```python
import open3d as o3d
import numpy as np

def render_offscreen(geo:o3d.geometry, output_path:str):

renderer = o3d.visualization.rendering.OffscreenRenderer(512, 512)
renderer.scene.set_background([1.0, 1.0, 1.0, 1.0])
material = o3d.visualization.rendering.MaterialRecord()

renderer.scene.add_geometry("bunny", geo, material)

bounds = geometry.get_axis_aligned_bounding_box()
center = bounds.get_center()
extent = bounds.get_extent()
max_extent = np.max(extent)

cam_distance = max_extent * 1.2
eye = center + np.array([0.0, 0.0, cam_distance])
up = np.array([0.0, 1.0, 0.0])
vertical_fov = 60.0

renderer.scene.camera.look_at(center, eye, up)
renderer.scene.camera.set_projection(
vertical_fov,
width / height,
0.1,
1000.0,
o3d.visualization.rendering.Camera.FovType.Vertical
)

img = renderer.render_to_image()
o3d.io.write_image(output_path, img)
```

### Error message

This will generate an output similar to this:

[Open3D INFO] EGL headless mode enabled.
FEngine (64 bits) created at 0x2fa3d850 (threading is enabled)
EGL(1.5)
OpenGL(4.6)

### Expected behavior

Only the
[Open3D INFO] EGL headless mode enabled.
Line should appear,

If I set the verbosity to Error there should not be any output in the console

### Open3D, Python and System information

```markdown
- Operating system: Fedora 42/ Ubuntu 22.04
- Python version: Python 3.11.0
- Open3D version: 0.19.0
- System architecture: x86
- Is this a remote workstation?: no
- How did you install Open3D?: pip
- Compiler version (if built from source): ❌
```

### Additional information

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.