I built an open-source basketball highlight pipeline here's how I improved vertical framing from 49% to 94%
说明与用途
作者通过集成篮球专用YOLOv8模型、相机运动补偿、OCR和裁剪规划,将篮球高光视频的垂直裁剪准确率从49%提升至94%。
问题
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.
结果
Ball inside crop increased from 49% to 94%; rim visibility from 43% to 98%; backboard edge visibility from 32% to 96% in evaluated frames.
工作流
- 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.
证据
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.
- 记录日期: 2026-10-21T21:11:23.481Z