def dump_one_lmdb(path, offset):
with lmdb.open(path, map_size=map_size) as env, \
env.begin().cursor() as lmdb_cursor:
num_entries = env.stat()['entries']
# Unfortunately, it seems the only way to set the cursor to an
# arbitrary key index (without knowing the key) is to literally call
# next() repeatedly.
lmdb_cursor.next()
for i in tqdm(range(offset)):
lmdb_cursor.next()
video_frame = video_frames_pb2.LabeledVideoFrame()
video_frame.ParseFromString(lmdb_cursor.value())
image_proto = video_frame.frame.image
image = np.fromstring(image_proto.data,
dtype=np.uint8).reshape(
image_proto.channels, image_proto.height,
image_proto.width).transpose((1, 2, 0))
image = Image.fromarray(image, 'RGB')
image.save('tmp.png')
print(lmdb_cursor.key())
print(', '.join([label.name for label in video_frame.label]))
show_one_labeled_video_frame.py 文件源码
python
阅读 16
收藏 0
点赞 0
评论 0
评论列表
文章目录