isl-org / isl-org/Open3D

OffscreenRender quality is very poor compared to Visualizer

Open
#5,689 9 comments 1 reaction 1 assignee Claimed by @errissa 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](http://www.open3d.org/docs/latest/getting_started.html#development-version-pip).
- [X] I have checked the [release documentation](http://www.open3d.org/docs/release/) and the [latest documentation](http://www.open3d.org/docs/latest/) (for `master` branch).

### Describe the issue

I'm am saving a screen capture of a textured 3D model and notice that the quality is very low and blurred using the `OffscreenRenderer` compared to the normal `Visualizer` when using the same resolution.

`Visualizer`
![visualizer](https://user-images.githubusercontent.com/590151/201729494-91a094e6-4778-4fed-b9b2-c0673c30d47b.png)

`OffscreenRenderer`
![lit](https://user-images.githubusercontent.com/590151/201729593-b995e9d2-ac6b-4797-aabb-bd37b4e43888.png)

### Steps to reproduce the bug

*OffscreenRenderer Version*
```python
import os
os.environ['OPEN3D_CPU_RENDERING'] = "true"

import open3d as o3d
import open3d.visualization.rendering as rendering
import glob
import numpy as np

def main():
render = o3d.visualization.rendering.OffscreenRenderer(width=640, height=640)

# https://www.dropbox.com/s/4e3s2iae3jxih0h/palm.zip?dl=1
mesh = o3d.io.read_triangle_model(f'palm/model.obj')

render.scene.add_model(f'mesh', mesh)
cam = o3d.camera.PinholeCameraParameters()
cam.extrinsic = np.asarray([[1,0,0,0],[0,1,0,0],[0,0,1,150],[0,0,0,1]])
cam.intrinsic = o3d.camera.PinholeCameraIntrinsic(640, 640, 640, 640, 320, 320)
render.setup_camera(cam.intrinsic, cam.extrinsic)

# Save screenshot
image = render.render_to_image()
o3d.io.write_image("headless.png", image, 9)

# # Save screenshot. Maybe lights improve things? (Nope)
render.scene.scene.set_sun_light([0.0, 0.0, 0.0], [1.0, 1.0, 1.0],100000)
render.scene.scene.enable_sun_light(True)
image = render.render_to_image()
o3d.io.write_image("headless-lit.png", image, 9)

if __name__ == "__main__":
main()
```

*Visualizer Version*
```python
import numpy as np
import open3d as o3d
import cv2
if __name__ == "__main__":
# https://www.dropbox.com/s/4e3s2iae3jxih0h/palm.zip?dl=1
pcd = o3d.io.read_triangle_mesh(f'palm/model.obj', True)

vis = o3d.visualization.Visualizer()
vis.create_window(window_name="Open3D", width=640, height=640, visible=False)
opt = vis.get_render_option()
opt.point_size = 5.0
opt.background_color = [1, 1, 1]
opt.line_width = 1
vis.add_geometry(pcd)
vis.poll_events()
vis.update_renderer()

# Save screenshot
buf = vis.capture_screen_float_buffer()
buf = np.asarray(buf)
buf = (buf * 255.).astype('uint8')
buf = cv2.cvtColor(buf, cv2.COLOR_RGB2BGR)
cv2.imwrite('visualizer.png', buf)
vis.destroy_window()
```

### Error message

None.

### Expected behavior

Same quality screen capture.

### Open3D, Python and System information

```markdown
- Operating system: macOS 12.6
- Python version: Python 3.7
- Open3D version: `0.15.1` for Visualizer 0.16.1 for OffscreenRenderer
- System architecture: M1
- Is this a remote workstation?: no
- How did you install Open3D?: pip
```

The mesh used is available from the link in the comment.

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.