iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🦴

3D Skeleton Detection for Pitching and Hitting Using Driveline C3D Data

に公開

Introduction

I visualized baseball players' forms in 3D and explored the relationship between joint movements and pitching velocity.

I used the following three tools:

  • Driveline OpenBiomechanics Project (OBP) — Professional-level motion capture C3D data (100 pitchers + 98 hitters)
  • ezc3d — C3D file reading/writing library (MIT License, GitHub)
  • matplotlib — 3D visualization and animation

GitHub: https://github.com/yasumorishima/baseball-cv

Involvement with ezc3d

Actually, I contributed a bug fix to ezc3d in PR #384. It turned out that I ended up using a library I contributed to for actual analysis.


Step 1: Visualizing 3D Skeletons from C3D Data

C3D files record the 3D coordinates of each marker (various body parts) captured by motion capture.

  • Pitching Data: 45 markers, 360Hz, approx. 726 frames
  • Hitting Data: 55 markers (45 body + 10 bat), 360Hz, approx. 804 frames

Read with ezc3d and visualize with matplotlib.

import ezc3d

c3d = ezc3d.c3d("pitching_sample.c3d")
points = c3d["data"]["points"]  # shape: (4, n_markers, n_frames)
labels = c3d["parameters"]["POINT"]["LABELS"]["value"]

Pitching Form Skeleton Animation

投球骨格アニメーション

45 markers are connected to draw the skeleton. A series of movements from wind-up to release can be seen.

Hitting Form Skeleton

打撃骨格

For hitting, there are 55 markers, with the 10 bat markers displayed in red.


Step 2: Skeleton Detection in General Videos (MediaPipe)

Even without motion capture equipment, skeletons can be detected from ordinary videos taken with a smartphone. Using Google's MediaPipe Pose, 33 joint points can be automatically detected in real-time from a single video.

import mediapipe as mp

mp_pose = mp.solutions.pose
pose = mp_pose.Pose(
    static_image_mode=False,
    min_detection_confidence=0.5,
    min_tracking_confidence=0.5
)

While this article's analysis uses Driveline OBP's C3D data (from dedicated sensors), MediaPipe can be a starting point if you want to try it easily.


Step 3: Extracting Joint Angles and Angular Velocities

We calculated "how much each joint moves (angle)" and "how fast it moves (angular velocity)" throughout the entire pitching motion.

Pitching

Joint Angle Min Value Max Value
Elbow Flexion 50.5° 156.7°
Shoulder Abduction 4.6° 117.7°
Trunk Rotation 58°
Knee Flexion 99.1° 163.8°

For example, elbow flexion moves within a range of 50-157°, indicating significant bending and straightening during the pitch. Trunk rotation, at 0-58°, might seem less significant compared to arm movements, but it emerges as the strongest correlate with ball speed in later analysis.

Time Series of Angular Velocity (Pitching)

Time series of joint angular velocity

This plots how many degrees each joint rotates per second (angular velocity) for each frame. It clearly shows which joints are moving particularly fast at which moment during the pitch.


Step 4: Correlation Analysis of Skeleton Movement × Ball Speed

The C3D data from Driveline OBP includes ball speed information in the filename (e.g., ..._809.c3d → 80.9 mph).

Using data from 16 pitchers, we investigated the correlation between indicators extracted from skeleton movement (angles, velocities, rotation amounts, etc.) and ball speed.

Correlation Results

Correlation scatter plot

Correlation matrix

Indicator Correlation (r) p-value
Peak Trunk Angular Velocity 0.119 0.673
Peak Elbow Angular Velocity 0.094 0.739
Peak Shoulder Abduction 0.180 0.520
Trunk Rotation Range 0.425 0.114

The correlation coefficient (r) ranges from -1 to +1, with values closer to 1 indicating a strong positive relationship where if one value is large, the other is also large. A p-value below 0.05 is generally considered statistically significant, but with only 16 participants, we cannot make definitive statements. Nevertheless, the trunk rotation range showed the strongest positive correlation (r=0.425) with ball speed. This suggests that "how much one can rotate the trunk" might be related to ball speed. More definitive results can be expected with a larger sample size.


Technology Stack

Technology Purpose
ezc3d C3D file reading
MediaPipe Pose Skeleton detection from video
matplotlib 3D visualization and GIF animation
numpy / scipy Angle calculation / Linear interpolation

Summary

  • Visualized 3D skeletons from Driveline OBP's C3D data using ezc3d.
  • Extracted time series of joint angles and angular velocities, observing characteristics across pitching phases.
  • Trunk rotation range showed the highest correlation (r=0.425) with ball speed.
  • MediaPipe allows skeleton detection from general videos (this analysis used motion capture C3D data).

Combining motion capture data with Statcast pitch quality data has the potential to help improve player performance.

GitHub: https://github.com/yasumorishima/baseball-cv

Data: Driveline OpenBiomechanics Project (CC BY-NC-SA 4.0)
ezc3d: pyomeca/ezc3d (MIT License)

GitHubで編集を提案

Discussion