How ramindu-nimex/netlytics works
Project type and purpose
• Netlytics is an open-source video-analytics tool that measures tennis player speed, shot speed, and shot count by processing input video frames.
• It uses YOLO (v8/v5) for object detection, PyTorch CNNs for court keypoint extraction, OpenCV for image processing, and Python utilities for tracking and statistics.
File structure
• Top level:
– main.py (orchestrator)
– yolo_inference.py (YOLO detection wrapper)
– constants/ (configuration values)
– utils/ (shared helpers: bbox manipulation, video I/O, drawing)
– court_line_detector/ (CNN court‐keypoint extraction)
– mini_court/ (court transform / homography)
– trackers/ (ball_tracker.py, player_tracker.py)
– training/ (Jupyter notebooks for model training)
• External artifacts:
– tracker_stubs/ (sample detection pickles)
– Pretrained model links in README
README
• Confirms architecture: video→YOLO detectors→CNN keypoints→tracking→metrics→annotated video.
• Lists dependencies: ultralytics (YOLO), PyTorch, OpenCV, pandas, numpy, supervision.
Main components and data flows
a. Components:
1. Video Input Module (utils/video_utils.py)
2. YOLO Detection Module (yolo_inference.py)
• Player Detector (YOLOv8)
• Ball Detector (fine-tuned YOLOv5)
3. Court Keypoint Module (court_line_detector/court_line_detector.py)
4. Court Homography Module (mini_court/mini_court.py)
5. Object Trackers (trackers/player_tracker.py, trackers/ball_tracker.py)
6. Analytics & Drawing Module (utils/player_stats_drawer_utils.py)
7. Video Output Module (utils/video_utils.py)
8. Training Notebooks (training/…) – separate sub-pipeline
b. Relationships & interactions:
– The Video Input feeds frames to the YOLO Detection Module and the Court Keypoint Module in parallel.
– Detections + Keypoints flow into the Court Homography Module to map image to court coordinates.
– Trackers consume detection coordinates (and optionally homography results) to maintain object identities across frames.
– The Analytics Module computes speed and shot metrics from tracks.
c. Architectural patterns:
– Pipeline pattern: clear sequential processing stages
– Modular separation: detection, transformation, tracking, analytics, I/O
– Reuse of utility libraries for image ops and data conversion
d. Key technologies:
– Python 3.8
– ultralytics (YOLOv8), PyTorch (CNNs)
– OpenCV (video I/O, drawing, perspective transforms)
– pandas, numpy (data manipulation)
– supervision (optional utilities)
Details to capture
– Notes on configuration (constants folder).
– Training workflow separated off the main pipeline but linked for context.
– The main.py orchestrator at the top, connecting all runtime modules in sequence.