Skip to content

Commit 3eaf831

Browse files
Added Project Documentation and README for Baseball Injury Risk Analysis (#284)
Co-authored-by: Ben Stephens <ben.stephens@deakin.edu.au> Co-authored-by: ben-AI-cybersec <142491786+ben-AI-cybersec@users.noreply.github.com>
1 parent 45a39ac commit 3eaf831

2 files changed

Lines changed: 114 additions & 0 deletions

File tree

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# Baseball Injury Risk Analysis — Project Documentation
2+
3+
## Table of Contents
4+
- [Introduction](#introduction)
5+
- [Problem Statement](#problem-statement)
6+
- [Project Objectives](#project-objectives)
7+
- [Technology Stack and Rationale](#technology-stack-and-rationale)
8+
- [System Architecture](#system-architecture)
9+
- [Dataset Development](#dataset-development)
10+
- [Model Training](#model-training)
11+
- [Challenges and Limitations](#challenges-and-limitations)
12+
- [Key Features](#key-features)
13+
- [Future Work](#future-work)
14+
- [Conclusion](#conclusion)
15+
16+
---
17+
18+
## Introduction
19+
20+
The **Baseball Injury Risk Assessment** project provides an intelligent system to analyze baseball player movements from video footage and assess injury risk. Using computer vision and machine learning, it detects risk-prone joint movements and outputs visual feedback with pose overlays and injury predictions.
21+
22+
## Problem Statement
23+
24+
Athletes in baseball face frequent injury risks due to repetitive motions. Traditional analysis methods are manual, subjective, and slow. This project introduces an automated, objective tool to classify movement risk levels from video data.
25+
26+
## Project Objectives
27+
28+
- Extract pose landmarks using MediaPipe.
29+
- Compute key joint angles (shoulder, elbow, knee).
30+
- Train a model to classify movement risk.
31+
- Overlay risk labels and visual feedback on video.
32+
- Build a Streamlit-based web interface for users.
33+
34+
## Technology Stack and Rationale
35+
36+
- **Pose Estimation**: MediaPipe — fast, efficient, and real-time.
37+
- **Model Training**: TensorFlow (Keras) — flexible and browser-friendly.
38+
- **Frontend**: Streamlit — lightweight, Python-native UI framework.
39+
- **Backend**: OpenCV — handles video processing and frame annotations.
40+
41+
## System Architecture
42+
43+
### Main Scripts
44+
- `main.py`: End-to-end processing (video → prediction → overlay).
45+
- `streamlit_app.py`: Web interface, handles upload and display.
46+
47+
### Utility Scripts
48+
- `utils/angles.py`: Calculates joint angles via cosine rule.
49+
- `utils/draw_overlay.py`: Draws skeletons, angles, and risk labels.
50+
- `model/predictor.py`: Loads the trained model and makes predictions.
51+
- `model/trainer.py`: Trains a classifier using joint angle data.
52+
- `config.py`: Central settings for paths, constants, and configs.
53+
- `dataset/label_mapper.py`: Converts string labels to numeric and vice versa.
54+
55+
## Dataset Development
56+
57+
The dataset consists of joint angle data extracted from 4 baseball videos:
58+
59+
- **High-risk pitchers**: Drew Storen, Max Scherzer (shoulder/elbow risk).
60+
- **Low-risk batters**: George Springer, Luis Arraez (safe movement).
61+
62+
Landmarks → Joint angles → CSV format:
63+
`[left_elbow, right_elbow, left_shoulder, right_shoulder, left_knee, right_knee, label]`
64+
65+
## Model Training
66+
67+
- **Model type**: Feedforward Neural Network
68+
- **Input**: 6 joint angles
69+
- **Output**: Risk class (`safe`, `shoulder risk`, `elbow risk`)
70+
- **Architecture**:
71+
- Input layer: 6 units
72+
- Hidden layer: 64 units, ReLU
73+
- Output layer: softmax over 3 classes
74+
75+
Trained using Adam optimizer and categorical crossentropy. Saved as `.h5` for runtime prediction.
76+
77+
## Challenges and Limitations
78+
79+
- **Pose Estimation Errors**: MediaPipe struggles with blur/occlusion.
80+
- **Small Dataset**: Only 4 videos — potential overfitting.
81+
- **Deployment Constraints**: Memory and time limits in hosting platforms.
82+
- **Label Noise**: Labels applied at video level, not frame-specific.
83+
84+
## Key Features
85+
86+
- **Video-Based Risk Assessment**: Annotated pose + risk feedback
87+
- **Web Interface**:
88+
- Upload videos
89+
- View progress with spinner
90+
- Download risk-annotated output
91+
92+
- **Modular Design**:
93+
- Replaceable pose or classification modules
94+
- Easily extendable to other sports
95+
96+
## Future Work
97+
98+
- Real-time webcam-based risk detection.
99+
- Larger, diverse datasets for robust training.
100+
- Frame-level joint-specific risk localization.
101+
- Expand to other sports like cricket, tennis, football.
102+
103+
## Conclusion
104+
105+
This capstone delivers a complete ML pipeline for video-based injury risk assessment in baseball. It demonstrates practical integration of computer vision, web development, and machine learning to solve real-world biomechanical problems in sports.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"label": "Baseball",
3+
"position": 1,
4+
"link": {
5+
"type": "generated-index",
6+
"description": "Find all the baseball here."
7+
}
8+
}
9+

0 commit comments

Comments
 (0)