mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-08-22 00:33:44 +08:00
Script to extract thumbnails from segment (#22294)
* Script to extract thumnails from segment * fix name * whitespace old-commit-hash: 8a836b7e1eb65b4a59a5be25f8b7dce9e2bedd0b
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
jpegs/
|
||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
from tqdm import tqdm
|
||||||
|
|
||||||
|
from common.file_helpers import mkdirs_exists_ok
|
||||||
|
from tools.lib.logreader import LogReader
|
||||||
|
from tools.lib.route import Route
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("route", help="The route name")
|
||||||
|
parser.add_argument("segment", type=int, help="The index of the segment")
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
out_path = os.path.join("jpegs", f"{args.route.replace('|', '_')}_{args.segment}")
|
||||||
|
mkdirs_exists_ok(out_path)
|
||||||
|
|
||||||
|
r = Route(args.route)
|
||||||
|
lr = list(LogReader(r.qlog_paths()[args.segment]))
|
||||||
|
|
||||||
|
for msg in tqdm(lr):
|
||||||
|
if msg.which() == 'thumbnail':
|
||||||
|
with open(os.path.join(out_path, f"{msg.thumbnail.frameId}.jpg"), 'wb') as f:
|
||||||
|
f.write(msg.thumbnail.thumbnail)
|
||||||
Reference in New Issue
Block a user