diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d65b68b13d..e559d87b3b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,7 +17,7 @@ repos: - id: flake8 exclude: '^(pyextra)|(external)|(cereal)|(rednose)|(panda)|(laika)|(opendbc)|(laika_repo)|(rednose_repo)/' args: - - --ignore=E111,E114,E121,E122,E123,E124,E126,E127,E128,E201,E202,E203,E226,E241,E265,E266,E302,E305,E402,E501,E722,E741,W504 + - --ignore=E111,E114,E121,E122,E123,E124,E126,E127,E128,E201,E202,E203,E226,E241,E265,E266,E302,E305,E402,E501,E722,E741,W504,W391 - --statistics - repo: local hooks: diff --git a/tools/scripts/fetch_image_from_route.py b/tools/scripts/fetch_image_from_route.py new file mode 100755 index 0000000000..e9111d9de2 --- /dev/null +++ b/tools/scripts/fetch_image_from_route.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python3 +import sys + +if len(sys.argv) < 4: + print("%s " % sys.argv[0]) + print('example: ./fetch_image_from_route.py "02c45f73a2e5c6e9|2020-06-01--18-03-08" 3 500') + exit(0) + +import requests +from PIL import Image +from tools.lib.auth_config import get_token +from tools.lib.framereader import FrameReader + +jwt = get_token() + +route = sys.argv[1] +segment = int(sys.argv[2]) +frame = int(sys.argv[3]) + +url = 'https://api.commadotai.com/v1/route/'+sys.argv[1]+"/files" +r = requests.get(url, headers={"Authorization": "JWT "+jwt}) +assert r.status_code == 200 +print("got api response") + +cameras = r.json()['cameras'] +if segment >= len(cameras): + raise Exception("segment %d not found, got %d segments" % (segment, len(cameras))) + +fr = FrameReader(cameras[segment]) +if frame >= fr.frame_count: + raise Exception("frame %d not found, got %d frames" % (frame, fr.frame_count)) + +im = Image.fromarray(fr.get(frame, count=1, pix_fmt="rgb24")[0]) +fn = "uxxx_"+route.replace("|", "_")+"_%d_%d.png" % (segment, frame) +im.save(fn) +print("saved %s" % fn) +