Skip to content

A machine learning Python app for computer vision-based detection and training to analyze NHL game clips

License

Notifications You must be signed in to change notification settings

danielrzhang/SnapShot

Repository files navigation

SnapShot

SnapShot is a Python application that analyzes hockey game video clips using YOLO object detection, custom machine learning models, and Roboflow datasets. It automatically annotates key gameplay elements, processing videos frame-by-frame with computer vision techniques and a deep convolutional neural network. The tool outputs annotated videos and statistical summaries, ideal for clips of 30 to 120 seconds to ensure fast processing and accurate results. SnapShot is designed for coaches, analysts, and hockey enthusiasts to break down gameplay dynamics efficiently.

Watch a sample of SnapShot in action:

Before SnapShot Processing

nhl.mp4

After SnapShot Processing

nhl.mp4

Features

  • Player Annotation by Team: Labels players from opposing teams with position markers and team-specific identifiers using advanced classification.
  • Puck Position Tracking: Tracks the puck’s location and visualizes its estimated path in each frame.
  • Puck Possession Detection: Identifies which player or team controls the puck based on proximity and movement patterns.
  • Rink Keypoint Detection: Detects rink keypoints (e.g., center ice, blue lines, goal lines) for perspective correction, zone identification, and spatial analytics.
  • Pass and Interception Detection: Tracks successful passes within each team and interceptions caused by opponent actions.
  • Puck Possession Percentage: Calculates each team’s puck possession time as a percentage of the clip’s duration.
  • Custom Models: Utilizes pre-trained Roboflow datasets and a custom YOLO model for accurate object detection.

YOLO Training Summary

The training for the puck, player, and rink models was conducted locally on the hardware specified below.

⚠️ Note: A GPU is required for efficient training; using a CPU alone significantly increases processing time and may cause performance issues.

Training Device Specs

  • CPU: Intel Core Ultra 7 155H
  • GPU: NVIDIA RTX 3000 Ada

Training Times

  • Player Recognition: 18 hours (on a dataset of ~3,500 images, 100 epochs)
  • Puck Recognition: 56 hours (on a dataset of ~47,000 images, 500 epochs)
  • Rink Keypoints: 8 hours (on a dataset of ~100 images, 500 epochs)

Datasets Used

Fine-Tuned Models

Requirements

  • Python: 3.10 or higher (tested with 3.13)
  • Dependencies:
    ultralytics
    pytorch
    roboflow
    opencv-python
    numpy

Work In Progress

  • Improved Puck Tracking: Enhance accuracy for high-speed puck movement, limited by camera frame rates, using advanced prediction algorithms.
  • Tactical Overview: Create a real-time overhead rink view using rink keypoints to visualize player positions, puck paths, and team strategies.
  • Offside Detection: Add rule-based logic to detect offside violations by tracking players entering the offensive zone ahead of the puck relative to blue lines.
  • Icing Detection: Detect icing by tracking puck shots from behind the center line crossing the opponent’s goal line without touches.
  • Goal Detection and Shot Analytics: Detect goals by monitoring puck proximity to the net and calculate shot speeds for analytics.

License

This project is licensed under the GNU General Public License. See LICENSE for details.

About

A machine learning Python app for computer vision-based detection and training to analyze NHL game clips

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published