Skip navigation
AI TENNIS ANALYSIS. A FULL COMPUTER VISION SYSTEM. BUILT ON YOLO, PYTORCH, AND KEYPOINT EXTRACTION.
0:00 / 4:41:24

AI TENNIS ANALYSIS. A FULL COMPUTER VISION SYSTEM. BUILT ON YOLO, PYTORCH, AND KEYPOINT EXTRACTION.

zostaff

18K followers

Visit on X
615 likesDownloadOriginal post

122,084 views

AI TENNIS ANALYSIS. A FULL COMPUTER VISION SYSTEM. BUILT ON YOLO, PYTORCH, AND KEYPOINT EXTRACTION. Take any tennis match broadcast, any camera angle, any resolution. Feed it into the pipeline. YOLO detects both players and the tennis ball frame by frame. No manual labeling, no pre-annotated dataset. A fine-tuned YOLOv5 model trained on a Roboflow tennis ball dataset handles the ball - the hardest object to track in any sport. Tiny, fast, constantly occluded. The model finds it anyway. Trackers maintain identity across frames so Player 1 stays Player 1 from the first serve to match point. But detection is just the start. A ResNet50 CNN trained in PyTorch predicts court keypoints from every frame - the corners, service lines, baselines, net posts. Fourteen points that define the entire playing surface geometry. From those keypoints the system builds a homography matrix and warps the broadcast perspective into a top-down mini court with real coordinates. Now every player has a position in real space, not pixel space. Every frame becomes a measurement. Every rally becomes a dataset. Player movement speed - calculated from position deltas between frames, converted to meters per second through the homography. Ball shot speed - measured from the ball trajectory across consecutive detections. Number of shots per rally - counted automatically through ball direction changes. All of this rendered live on the video as an overlay. A mini court in the corner showing both players as dots moving in real time. Stats updating after every point. OpenCV handles the rendering. Pandas handles the math. PyTorch handles the intelligence. YOLO handles the eyes. No Hawkeye subscription, no court-embedded sensors, no tracking chips in the ball. A Python script, a trained model, and a GPU. The full code is on GitHub. The tutorial walks through every module - from ball detector training to court keypoint extraction to the final statistical overlay. Professional teams used to need broadcast deals and proprietary hardware for this kind of analysis. Now you build it in an afternoon with open-source tools. Trading here: Computer vision didn't just enter tennis. It made the expensive stuff free.

31 Comments

Comments from the original post on X (Twitter)

  • Mauro Casas's profile picture

    @maurohouseless

    Pretty useless if you have latency, what you see on TV/online already has a few seconds of delay from the actual moment the swing happened. It's probably more effective to toss a coin, at least you get 50/50.

    3 likes

  • zostaff's profile picture

    @zostaff

    Well, if you want to do everything in real time, there are APIs for $12k a year that can feed you data with a 100-300ms delay

    2 likes

  • Mauro Casas's profile picture

    @maurohouseless

    Double click there. Why would you bet on the past and not the real time analysis? You have no edge.

    1 like

  • zostaff's profile picture

    @zostaff

    Bro, I build systems that help analyze matches, and I'm also adapting them into systems that analyze matches in real time. I'm not concerned about latency, since what matters to me is the overall analysis and the discrepancy between my model and the market.

    4 likes

  • Mauro Casas's profile picture

    @maurohouseless

    Let me sneak into your DMs.

  • zostaff's profile picture

    @zostaff

    my tg channel:

    3 likes

  • Gipp 🦅's profile picture

    @gippp69

    Thanks for the complete setup!

    2 likes

  • vorty's profile picture

    @vorty279

    even a vegan would eat this meat

    1 like

  • Steve's profile picture

    @steve_cook

    is this open source and MIT? do you have a demo for “any angle”?

    1 like

  • BuBBliK's profile picture

    @k1rallik

    pro-level tennis tracking for free… your broadcast, your GPU, your data

    1 like

  • Lummox's profile picture

    @Lummox_eth

    It makes sense to bet on tennis with the bot

    1 like

  • John Palmer's profile picture

    @johnpalmer

    Cc @Gill_Gross @ThreadOrder this is cool.

    1 like

  • BullsimusMaximus's profile picture

    @Weedthoughts33

    Is there one for Padel?

    1 like

  • Yield Architect's profile picture

    @TheYieldArch

    Tracking the ball is the "hello world" of sports CV, but mapping it to a top-down homography matrix is the real alpha. Moving from pixel-space to real-world metrics kills the legacy hardware moat instantly.

    1 like

  • grev's profile picture

    @greednvirtue

    That's unbelievable!

    1 like

  • Insomnia's profile picture

    @insomnia_vip

    new way to trade win AI

    1 like

  • Ventry's profile picture

    @ventry089

    wow, looks cool bro hope this helps me

    1 like

  • zostaff's profile picture

    @zostaff

    ty broski

    1 like

  • Even Money Sniper's profile picture

    @evenmoneysniper

    👀👀👀

    1 like

  • tawer's profile picture

    @tawer1O

    Ball tracking in yolov5 struggles with heavy occlusion

    1 like