To reduce memory usage, we choose to store the jpeg strings of image instead of the numpy array in the buffer. This function encodes the observation numpy arr to the jpeg strings
(arr)
| 320 | |
| 321 | |
| 322 | def arr_to_str(arr): |
| 323 | """To reduce memory usage, we choose to store the jpeg strings of image instead of the numpy array in the buffer. |
| 324 | This function encodes the observation numpy arr to the jpeg strings |
| 325 | """ |
| 326 | img_str = cv2.imencode('.jpg', arr)[1].tobytes() |
| 327 | |
| 328 | return img_str |
| 329 | |
| 330 | |
| 331 | def str_to_arr(s, gray_scale=False): |