| 45 | |
| 46 | |
| 47 | class ImageEncode(MapDataComponent): |
| 48 | def __init__(self, ds, mode='.jpg', dtype=np.uint8, index=0): |
| 49 | def func(img): |
| 50 | img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) |
| 51 | return np.asarray(bytearray(cv2.imencode(mode, img)[1].tostring()), dtype=dtype) |
| 52 | super(ImageEncode, self).__init__(ds, func, index=index) |
| 53 | |
| 54 | |
| 55 | class ImageDecode(MapDataComponent): |