โณ 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
๐๏ธ Built For
- 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.
Video Tutorial:
Full Video Tutorial
๐ 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:
๐ Source Code & Notebook: https://github.com/ryanboscobanze/GolfPosePro
๐ Buy Me a Coffee โ
๐ฑ Follow Me
- X (Twitter): @RyanBanze
- Instagram: @aibanze
- LinkedIn: Ryan Banze



Top comments (0)