How toannguyenkhanh/badminton-analysis works
Project Type and Purpose
• The README clearly states that this is a computer vision project aimed at detecting badminton players and shuttlecocks during matches.
• Core functionality includes data preparation, training models for detection (using pretrained YOLO weights), and then using these models to analyze videos/images.
• The project is not a web service but a data processing and machine vision application with distinct training, detection, and tracking modules.
File Structure to Identify Main Components
a. Core Scripts and Entry Points
• main.py: Likely the primary entry for running analysis on videos or images.
• dataset.py and open_image.py: Utility scripts for handling datasets and image inputs.
• test_open_image.py: For unit testing image processing functions.
b. Tracking Module
• The tracker directory contains modules (player_tracker.py and shuttle_tracker.py) that likely encapsulate the logic for tracking the detected objects across frames.
c. Training Pipeline
• The train directory houses the training scripts and models:
• train.py as the driver for training.
• Separate directories for player_output and shuttle_output, each with model configuration files (args.yaml), event logs, results.csv, and model weights (best.pt, last.pt).
• Pretrained YOLO models (yolov8n.pt and yolov8s.pt) are also included here.
d. Utility Functions
• The utils directory includes video_utils.py, which is probably responsible for video processing tasks such as frame extraction, video writing, etc.
e. Miscellaneous
• The last_detect directory containing pkl files suggests that previous detection results might be cached or used for incremental processing.
Architectural Patterns & Relationships
• Input: Video/images (as indicated by dataset preparation and open_image.py).
• Preprocessing: dataset.py and video_utils.py for input handling.
• Model Inference: main.py likely coordinates the use of trained models to perform detection.
• Tracking: Tracker modules (player_tracker.py and shuttle_tracker.py) analyze detection output across frames.
• Training: train/train.py and related subdirectories manage model training and configuration.
Technology & Frameworks Highlighted
• Computer vision algorithms, particularly those related to object detection (YOLO models are used).
• Python as the primary programming language.
• YAML configuration files (args.yaml) that indicate customizable model parameters.
• Logging and results tracking for training (events.out.tfevents and results.csv).
Elements
• A “Preprocessing & Data Handling” component where dataset.py and utils/video_utils.py reside.
• A “Tracking Module” that directly interacts with the detection output (tracker/player_tracker.py, tracker/shuttle_tracker.py).
• An “Output/Results” component showcasing results such as the output video (output_video.mp4) and stored detection results (in last_detect and train outputs).