本文目录导读:

要统计“克鲁伊夫转身”做了几次,需要先明确数据来源和统计口径,下面给你一个可直接改造的实用脚本框架,适用于视频分析、比赛事件数据、或手动打点记录三种场景。
基于事件数据(JSON/CSV)统计
假设你有一份比赛事件数据,每条事件包含球员、动作类型、时间等字段:
import csv
from collections import Counter
def count_cruyff_turns(csv_path, player_name=None):
"""
统计克鲁伊夫转身次数
:param csv_path: 事件数据CSV,需包含 player, action, minute 列
:param player_name: 指定球员,None则统计全队
"""
count = 0
details = []
with open(csv_path, encoding='utf-8') as f:
reader = csv.DictReader(f)
for row in reader:
action = row['action'].strip().lower()
# 兼容多种写法
if action in ('cruyff turn', 'cruyff_turn', '克鲁伊夫转身'):
if player_name is None or row['player'] == player_name:
count += 1
details.append((row['minute'], row['player']))
return count, details
# 使用
n, detail = count_cruyff_turns('events.csv', player_name='梅西')
print(f"克鲁伊夫转身次数: {n}")
for d in detail:
print(f" 第{d[0]}分钟 - {d[1]}")
手动打点 + 快捷键记录(看录像时用)
看比赛录像时,按一个键记录一次,自动带时间戳:
import time
import keyboard # pip install keyboard
import json
records = []
print("按 [空格] 记录一次克鲁伊夫转身,按 [Esc] 结束")
start = time.time()
while True:
if keyboard.is_pressed('space'):
t = round(time.time() - start, 1)
records.append({'time_sec': t})
print(f"✅ 记录第 {len(records)} 次 @ {t}s")
time.sleep(0.3) # 防连按
if keyboard.is_pressed('esc'):
break
with open('cruyff_turns.json', 'w', encoding='utf-8') as f:
json.dump(records, f, ensure_ascii=False, indent=2)
print(f"\n共记录 {len(records)} 次克鲁伊夫转身")
视频 + 目标检测(进阶,需标注)
如果你要用计算机视觉自动识别,思路是:
- 姿态估计(MediaPipe / YOLO-Pose)提取球员关键点
- 定义规则:球在脚边 + 身体先向一侧倾斜 + 快速180°转向 + 用脚内侧拉球
- 状态机判定:
def is_cruyff_turn(prev_pose, curr_pose, ball_near_foot, dt):
"""
简化判定逻辑(需按实际数据调参)
"""
body_angle_change = abs(curr_pose['torso_yaw'] - prev_pose['torso_yaw'])
foot_speed = curr_pose['foot_velocity']
return (body_angle_change > 120 and # 转身角度大
ball_near_foot and # 球在脚附近
foot_speed > threshold and # 快速拉球
dt < 1.0) # 1秒内完成
⚠️ 纯视觉自动识别误判率高,实际项目通常需要人工复核或标注数据训练分类器。
建议
| 场景 | 推荐方案 |
|---|---|
| 有结构化事件数据 | 方案一(最快最准) |
| 看录像人工统计 | 方案二(效率高) |
| 想做自动化研究 | 方案三(需大量标注) |
统计口径提醒:要明确是否计入——被犯规中断的、训练中的、非正式比赛的,建议脚本里加 match_type 字段过滤。
需要我根据你的具体数据格式(Opta、StatsBomb、或自建表)写适配版吗?