How bahrombekk/train-number works
Project type and purpose
• This is a specialized video-processing pipeline (not a full-stack web app) for batch processing trains-of-interest. It uses computer vision and machine learning to detect train wagons and read their numbers.
• Purpose: Ingest multiple video files, detect wagons in frames via YOLO, recognize digits within each detection, validate them, and write annotated video + text/image outputs.
File structure
Top-level files and directories:
• main.py – Orchestrates processing of multiple videos in parallel
• video_processor.py – Implements the VideoProcessor class and the multi-threaded pipeline
• data.json – Configuration listing videos and model paths
• demo/ – Sample/demo scripts, data and outputs to illustrate functionality
• output/ – Default output directory structure for processed frames, images, text
• requirements.txt – Dependencies (OpenCV, PyTorch, etc.)
• number.txt / video files (not in repo)
Patterns:
• Pipeline / producer-consumer pattern with two message queues
• Multi-threading for CPU/GPU utilization
• File-system used as persistence (no database)
README for additional insights
• Main Class: VideoProcessor with methods setup_directories, frame_producer, frame_processor, frame_writer
• Main script loads data.json, spawns a thread per video to call process_video()
• Two models: YOLO object detection model + digit recognition model (PyTorch)
• Outputs:
– Annotated video file
– Text files of detected numbers
– Image snapshots of valid detections