PKU-Alignment / safety-gymnasium

NeurIPS 2023: Safety-Gymnasium: A Unified Safe Reinforcement Learning Benchmark
https://safety-gymnasium.readthedocs.io/en/latest/
Apache License 2.0
377 stars 52 forks source link

[Question] How to save images as videos in depth_array render mode? #27

Closed 1Asan closed 1 year ago

1Asan commented 1 year ago

Required prerequisites

Questions

Hi, I am using depth_array render mode. I will get a np.array array when I call env.render(), and I noticed that in safety-gymnasium/examples/vision_env.py, a example shows how to save the list of array as a video, but It's an rgb_array example, depth_array which has different dimensions can't work if I just follow that. Please give me some help. Thanks a lot.

friedmainfunction commented 1 year ago

Use this to pre-process the depth information into the intuitive image for humans:

        img = env.render()
        img = 1 - np.expand_dims(img, 2)
        img = (1 - ((np.repeat(img, 3, 2) - np.min(img)) / np.max(img))) * 255

Of course, This is actually just one way to show this information for humans, you can design your own style to show what you focus on. This is basically what my solution looks like: image

XuehaiPan commented 1 year ago

Closing due to inactivity. Feel free to ask to reopen it.