I built an open-source basketball highlight pipeline here's how I improved vertical framing from 49% to 94%
Description and use
The author increased vertical framing accuracy for basketball highlights from 49% to 94% by integrating a basketball‑trained YOLOv8 model, camera‑motion compensation, OCR, and a crop planner.
Problem
Standard basketball broadcasts are 16:9, but vertical short‑form videos are 9:16, causing important action such as the ball, players and rim to be cropped out.
Outcome
Ball inside crop increased from 49% to 94%; rim visibility from 43% to 98%; backboard edge visibility from 32% to 96% in evaluated frames.
Workflow
- Sample 256 frames from 32 NBA Finals highlights and label ball positions with Claude vision agents.
- Replace generic detector with E‑BARD basketball‑trained YOLOv8n.
- Apply a 0.10 confidence threshold and filter false positives using size, shape and position.
- Use OpenCV cv2.phaseCorrelate to estimate camera motion and link ball detections into tracks.
- Read scoreboard OCR to identify scoring moments.
- Plan a crop path that pans with ball trajectory and rim visibility, avoiding continuous zoom.
- Render 9:16 clips and measure ball and rim visibility against labeled moments.
Evidence
In the rendered vertical clips, the first version kept the ball inside the crop in just 85 of 172 evaluated frames: 49%.
The new basketball pipeline is available in version 2.1.
Instead of building a detector from scratch, I integrated E-BARD's basketball-trained YOLOv8n detection model.
The results from the first version compared with the current version were: Ball inside the crop: 85 of 172 frames (49%) in the first version, compared with 162 of 172 (94%) now.
The pipeline still struggles with some close‑ups, free throws, replays and broadcasts with closer camera angles.
- Record date: 2026-10-21T21:11:23.481Z