@@ -14,9 +14,10 @@ def render_geometries(
14
14
view_status_str : str = None ,
15
15
height : int = 720 ,
16
16
width : int = 1280 ,
17
- visible : bool = False ,
18
17
point_size : float = 1.0 ,
19
18
line_radius : float = None ,
19
+ to_depth = False ,
20
+ visible : bool = False ,
20
21
) -> None :
21
22
"""
22
23
Render Open3D geometries to an image. This function may require a display.
@@ -33,15 +34,17 @@ def render_geometries(
33
34
size and the point size.
34
35
height: int image height.
35
36
width: int image width.
36
- visible: bool whether to show the window.
37
37
point_size: float point size for point cloud objects.
38
38
line_radius: float line radius for line set objects, when set, the line
39
39
sets will be converted to cylinder meshes with the given radius.
40
40
The radius is in world metric space, not relative pixel space like
41
41
the point size.
42
+ to_depth: bool whether to render a depth image instead of RGB image.
43
+ visible: bool whether to show the window.
42
44
43
45
Returns:
44
- image: (H, W, 3) float32 np.ndarray image.
46
+ (H, W, 3) float32 np.ndarray RGB image by default; (H, W) float32
47
+ depth image if to_depth is True.
45
48
"""
46
49
47
50
if not isinstance (geometries , list ):
@@ -100,9 +103,12 @@ def render_geometries(
100
103
101
104
vis .poll_events ()
102
105
vis .update_renderer ()
103
- buffer = vis .capture_screen_float_buffer ()
106
+ if to_depth :
107
+ buffer = vis .capture_depth_float_buffer ()
108
+ else :
109
+ buffer = vis .capture_screen_float_buffer ()
104
110
vis .destroy_window ()
105
- im_buffer = np .asarray (buffer )
111
+ im_buffer = np .asarray (buffer ). astype ( np . float32 )
106
112
107
113
return im_buffer
108
114
0 commit comments