Built the Sentinel Tab
This commit is contained in:
40
backend/scripts/cctv_ocr_bridge.py
Normal file
40
backend/scripts/cctv_ocr_bridge.py
Normal file
@@ -0,0 +1,40 @@
|
||||
"""
|
||||
Bridge OCR/plate-recognition output into the Velocity CCTV ingestion API.
|
||||
|
||||
Usage:
|
||||
python backend/scripts/cctv_ocr_bridge.py --api-base https://host --session-id <uuid> payload.json
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
import httpx
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(description='Forward OCR bridge payloads to Velocity CCTV API.')
|
||||
parser.add_argument('payload', type=Path, help='Path to a JSON payload file from the OCR bridge.')
|
||||
parser.add_argument('--api-base', default='http://127.0.0.1:8000', help='Velocity API base URL.')
|
||||
parser.add_argument('--session-id', default=None, help='Optional auto mode perception session UUID.')
|
||||
parser.add_argument('--token', default=None, help='Optional bearer token for protected ingestion.')
|
||||
args = parser.parse_args()
|
||||
|
||||
body = json.loads(args.payload.read_text(encoding='utf-8'))
|
||||
if args.session_id:
|
||||
body['session_id'] = args.session_id
|
||||
|
||||
headers = {'Content-Type': 'application/json'}
|
||||
if args.token:
|
||||
headers['Authorization'] = f'Bearer {args.token}'
|
||||
|
||||
response = httpx.post(f"{args.api_base.rstrip('/')}/api/cctv/event", json=body, headers=headers, timeout=30.0)
|
||||
response.raise_for_status()
|
||||
print(json.dumps(response.json(), indent=2))
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user