This directory contains companion utilities for a running Plate Recognizer Stream installation. For Stream setup and configuration, see the Stream documentation.
video_upload.py uploads every file in a directory to Stream's
file-upload API
and appends successful responses to output.jsonl.
Install the directory's dependencies, then start the uploader:
python -m pip install -r requirements.txt
python video_upload.py /path/to/videosThe file-upload server defaults to http://localhost:8081. Use --sdk-url to
change it and --mask to select a camera mask.
stream_monitor.py reads a Stream container's Docker logs and exposes its
status over HTTP.
python stream_monitor.py --help
python stream_monitor.py --container stream --interval 30 --duration 120The server listens on localhost:8001 by default. Query it from another
terminal:
curl http://localhost:8001Example response:
{
"active": true,
"cameras": {
"camera-1": {"status": "running"},
"camera-2": {"status": "offline"}
}
}active reports whether the Stream container is running. A camera is marked
offline when it has not produced a recognized log entry within --duration
seconds.
remove_images.py recursively deletes .jpg files and then removes empty
directories. It supports two mutually exclusive cleanup modes:
- Age mode deletes images older than 1–23 hours.
- Disk-usage mode deletes the oldest images first when disk usage reaches a trigger percentage, stopping when the target free-space percentage is met.
This utility permanently deletes files. Test the command against a disposable directory before scheduling it against Stream data.
Delete images older than 23 hours:
python remove_images.py --age --threshold 23 --directory /path/to/streamWhen disk usage reaches 80%, delete the oldest images until at least 20% of the disk is free:
python remove_images.py \
--usage \
--trigger_usage 80 \
--target_free 20 \
--directory /path/to/streamRun python remove_images.py --help for the complete argument reference. If
you do not want Stream to save images at all, use the appropriate
Stream configuration
instead of periodically deleting them.
On Linux, add one selected cleanup command to cron. For example, this runs age cleanup every night at midnight:
0 0 * * * /usr/bin/python3 /path/to/remove_images.py --age --threshold 23 --directory /path/to/streamThis example checks disk usage every ten minutes:
*/10 * * * * /usr/bin/python3 /path/to/remove_images.py --usage --trigger_usage 80 --target_free 20 --directory /path/to/streamUse crontab -e for the account that owns the Stream files. If you edit
/etc/crontab instead, include the account name between the schedule and the
command.
On Windows, create a scheduled task in Command Prompt or PowerShell. The following example runs age cleanup daily at midnight:
schtasks /create /sc daily /tn RemoveStreamImages /tr "python C:\path\to\remove_images.py --age --threshold 23 --directory C:\PlateRecognizer\Stream" /st 00:00For disk-usage cleanup, use a distinct task name and command:
schtasks /create /sc minute /mo 10 /tn FreeUpStreamDiskSpace /tr "python C:\path\to\remove_images.py --usage --trigger_usage 80 --target_free 20 --directory C:\PlateRecognizer\Stream"To remove these tasks later:
schtasks /delete /tn RemoveStreamImages /f
schtasks /delete /tn FreeUpStreamDiskSpace /f