This content originally appeared on DEV Community and was authored by Ryan Banze
Why This Project Matters
Golf has always been a game of inches , a micro-adjustment in wrist angle, a fraction of a second in timing, or a subtle shift in posture can be the difference between a 300-yard drive and a slice into the trees.
Traditionally, only elite players with access to swing coaches, motion capture systems, or $10,000 launch monitors could dissect their biomechanics. Everyone else? We just squint at slow-mo YouTube replays of Tiger and hope for the best.
That gap is what I set out to solve.
What if anyone, anywhere, with nothing more than a smartphone video and a Colab notebook, could access near-pro-level swing diagnostics?
That was the genesis of GolfPosePro , an AI-powered golf swing analyzer that:
- Tracks your swing phases frame-by-frame with pose estimation.
- Visualizes biomechanics (like wrist trajectory) in debug plots.
- Compares your motion to PGA Tour pros , side-by-side.
- Generates enhanced playback with slow motion, labeled overlays, and pro benchmarks.
All built with Python, MediaPipe, OpenCV, matplotlib, and Google Colab Pro.
This isnβt just about golf β itβs a case study in democratizing biomechanics through AI.
What It Does
Extracts wrist motion from your swing video.
Segments swing phases dynamically:
Address β Backswing β Top β Downswing β Impact β Follow-through
Overlays debug plots of wrist trajectory, velocity, and key checkpoints.
Runs side-by-side comparisons against PGA swings (downloaded with yt-dlp).
Encodes slow-motion video segments, highlighting your motion frame-by-frame.

Imagine watching your swing next to Rory McIlroyβs β with a biomechanical plot showing exactly where your wrist path diverges.
How It Works
This project is really three systems working together:
- Pose Estimation Engine (MediaPipe) β Converts pixels into biomechanical landmarks.
- Signal Processing Layer (NumPy + matplotlib) β Smooths, filters, and segments motion.
- Visualization Pipeline (OpenCV + FFmpeg) β Merges raw video with analytical overlays.
Letβs break that down.
1. Pose Estimation with MediaPipe
At the heart of the system is MediaPipe Pose β Googleβs real-time human landmark detector.
It tracks 33 body landmarks at ~30 FPS, including wrists, shoulders, and hips.
results = pose.process(rgb_frame)
wrist_y = results.pose_landmarks.landmark[LEFT_WRIST].y
From a swing video, we extract wrist positions across time.β¨Why wrists? Because theyβre critical in determining swing path, lag, and release timing.
2. Trajectory Smoothing
Raw pose data is noisy (frames jitter, lighting shifts).β¨To stabilize it, I apply a uniform moving average filter and compute velocity with NumPy gradients.
velocity = np.gradient(uniform_filter1d(wrist_y, size=5))
This transforms jittery landmarks into smooth curves that actually mean something.
- Velocity spikes = transition points
- Flat zones = posture holds
3. Swing Phase Segmentation
Hereβs the biomechanical magic:
- Address β Backswing start = wrist first deviates upward.
- Top of swing = lowest wrist point (relative to torso).
- Impact = peak wrist acceleration crossing baseline.
- Follow-through = velocity decay + posture stabilization. Each phase is dynamically detected, then color-coded on the debug plot.
4. Side-by-Side Video Overlays
A coach doesnβt just tell you where youβre off β they show you.
So with OpenCV and FFmpeg, I stack:
- Your swing
- A proβs swing (downloaded via yt-dlp)
- Trajectory plots with labeled swing checkpoints
combined_frame = np.hstack((frame, debug_plot_img))
The final output: a video file with slow-motion playback at impact, plus real-time analytical overlays.
Tools Used
- Amateurs β Upload iPhone swing clips, get coach-like insights.
- Coaches β Use it as a feedback tool without expensive sensors.
- Developers β A sandbox for exploring pose detection + video analytics. This notebook isnβt replacing coaches or TrackMan β but itβs democratizing access to biomechanics.
Credits
- Pro swing footage: YouTube Shorts (Max Homa, Ludvig Γ berg).
- Frameworks: MediaPipe, OpenCV, matplotlib, FFmpeg.
- Countless test swings (and slices) on the driving range.
Whatβs Next
AI coach commentary overlay.
Support for left-handed players (pose normalization).
Ball tracer integration.
Automatic swing grading with ML classifiers.
Mobile-friendly UI.
Final Thoughts
Golf is often said to be a battle between the player and themselves.β¨By applying AI pose detection, we finally have a way to quantify the invisible β turning milliseconds of motion into data you can act on.
This project isnβt just about golf.β¨Itβs a glimpse of how AI can democratize performance analysis across all sports.
And for me? Itβs about making practice smarter, not just longer.
Letβs bring AI to the range β one frame at a time
If you enjoyed this project, consider buying me a coffee to support more free AI tutorials and tools:
Buy Me a Coffee
Follow Me
- X (Twitter): @RyanBanze
- Instagram: @aibanze
- LinkedIn: Ryan Banze
This content originally appeared on DEV Community and was authored by Ryan Banze

