apopt.comCBE 493R Data-Driven Athletics

Course / Tutorials / Week 1 / CS-1

Case study CS-1 · Week 1 · about 60 min · Foundation

How high did I jump?

Measure one countermovement jump three ways from a slow-motion phone clip (a frame count, the rise of the hips in pose keypoints, and the jump app's own formula), decide which to trust, and start the athlete record.

  1. 1Gather (used)
  2. 2Statistics (used)
  3. 3Visualize (used)
  4. 4Cleanse (used)
  5. 5Features
  6. 6Balance
  7. 7Scale
  8. 8Split
  9. 9Deploy
  1. Ask (this week)
  2. Collect (this week)
  3. Check (this week)
  4. Interpret (this week)
  5. Coach (this week)
  6. Reassess

8 of 10 cells run in this page. The rest need a model that does not run in the browser: run them in the notebook on your computer or in Colab (File → Upload notebook); their output from the course build is shown, and the files they write are published so the later cells still run here. Helpful first: Q-1 Run your first cell and change one number, Q-2 Step through a video one frame at a time.

The decision

An athlete wants to add a short jump block to her week and retest in six weeks. That decision needs one jump height she can repeat, and a number for how big a change must be before it is real. If the methods disagreed by less than a centimeter, any of them would do; if they disagree by much more, you must choose one and say why.

Predict first

The clip is a recreational adult's countermovement jump. Before any code: how high do you expect it to be, in centimeters, and will a frame count and the rise of the hips agree within 2 cm?

The raw data

Data dictionary
FieldMeaningUnitRangeMissing
frameframe number in the filecount0–189never missing
<joint>_x, <joint>_ykeypoint position for 17 joints (nose … r_ankle)pixels from the top-left corner; y grows downward0–1080, 0–1920empty after the confidence gate
<joint>_cthe model's confidence in that keypoint0 to 10–1never missing
diff_prevmean absolute gray-level difference from the previous framegray levels (0–255)0–5 heremissing for frame 0
repeatthe frame repeats the one before it (diff_prev < 0.5)true/false—never missing

What is wrong with it: the header says 30 frames per second although the camera recorded 120; every sixth frame repeats the one before it (32 of 190); the clip is filmed from behind, so the face and eyes are hidden; it is hand-held, and the feet sink into grass. Each of these changes a different method.

Step by step

Step 1 · Gather: what is in the clip?

One countermovement jump, filmed in slow motion on a phone: the course's example clip jump2_120fps.mp4 (Section 1.3, Example "A hand count on the course's example clip"). It is filmed from behind, hand-held, on grass. You will measure the jump three ways: by counting frames, from the rise of the hips in a pose model's keypoints, and with the jump app's own formula, then decide what the jump height is and how sure you can be.

The first two cells read the video, so they run on your own computer or in Colab. They write tables with no pictures in them; from Step 2 on, everything runs in this page from those tables.

Step 1 · Read the clip's header

Runs in the notebook (needs a model that does not run in the browser). Output from the course build:

import cv2

cap = cv2.VideoCapture("local/jump2_120fps.mp4")
fps_file = cap.get(cv2.CAP_PROP_FPS)
n = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
w, h = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)), int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
print(f"{n} frames, header {fps_file:.2f} fps, {w} x {h} pixels (portrait)")
print(f"{n / fps_file:.2f} s on the file's clock, {n / 120:.2f} s at the 120 fps capture rate")
cap.release()
190 frames, header 30.00 fps, 1080 x 1920 pixels (portrait)
6.33 s on the file's clock, 1.58 s at the 120 fps capture rate

The header says 30. The phone recorded 120 frames a second and stored them to play back four times slower. Every time in this study is a frame count divided by 120, the capture rate; dividing by 30 is the slow-motion trap of Section 1.3.2.

The next cell runs a pose model (Chapter 8 explains it) on every frame and keeps, for each frame, the x and y of 17 keypoints in pixels and the model's confidence in each. It also measures how much each frame differs from the one before, because a frame that repeats the previous one is not a new moment (Q-2).

Step 1 · Keypoints and a repeat check for every frame

Runs in the notebook (needs a model that does not run in the browser). Output from the course build:

import os
import numpy as np
import pandas as pd
from ultralytics import YOLO

NAMES = ["nose", "l_eye", "r_eye", "l_ear", "r_ear", "l_shoulder", "r_shoulder", "l_elbow", "r_elbow",
         "l_wrist", "r_wrist", "l_hip", "r_hip", "l_knee", "r_knee", "l_ankle", "r_ankle"]
os.makedirs("clean", exist_ok=True)
model = YOLO("yolo26s-pose.pt")
cap = cv2.VideoCapture("local/jump2_120fps.mp4")
rows, check, prev, i = [], [], None, 0
while True:
    ok, frame = cap.read()
    if not ok:
        break
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY).astype(float)
    check.append([i, np.nan if prev is None else np.abs(gray - prev).mean()])
    r = model(frame, verbose=False, device="cpu")[0]
    if r.keypoints is not None and len(r.boxes):
        best = int(r.boxes.conf.argmax())                  # the most confident person
        xy, conf = r.keypoints.xy[best].tolist(), r.keypoints.conf[best].tolist()
        rows.append([i] + [v for p in xy for v in p] + conf)
    prev, i = gray, i + 1
cols = ["frame"] + [f"{k}_{a}" for k in NAMES for a in "xy"] + [f"{k}_c" for k in NAMES]
pd.DataFrame(rows, columns=cols).round(2).to_csv("clean/keypoints.csv", index=False)
pd.DataFrame(check, columns=["frame", "diff_prev"]).round(3).to_csv("clean/frame_check.csv", index=False)
print(f"person found in {len(rows)} of {i} frames")
person found in 190 of 190 frames

Step 2 · Statistics: what did the model see?

A profile first. How sure is the model of each joint, and how many frames are repeats?

PythonStep 2 · Confidence by joint, and repeated frames

Type a prediction to enable Run.

Show the expected result without running
r_eye         0.01
nose          0.02
l_eye         0.02
r_ear         0.79
l_ear         0.83
r_wrist       0.84
l_wrist       0.91
l_ankle       0.94
r_ankle       0.95
r_elbow       0.97
l_elbow       0.99
r_shoulder    1.00
l_shoulder    1.00
l_hip         1.00
r_hip         1.00
l_knee        1.00
r_knee        1.00
190 frames; 32 repeat the frame before, every 6th frame

The eyes and nose have a median confidence near zero: from behind, the face is hidden, and the model is telling the truth. The ears, hips, knees and ankles are found with confidence 0.8 or more. And 32 frames, every sixth one, repeat the frame before. That is a fault of the file, not of the jump; Step 4 decides what to do about it.

Step 3 · Visualize: the jump without the pixels

Draw the keypoints as stick figures at five moments, and plot two traces over the whole clip: the hip midpoint (the middle of the two hips, the point the jump app follows) and the lower of the two ankles. Pixel y grows downward, so the traces are flipped to make up mean up.

PythonStep 3 · Five moments and two traces

Show the expected result without running
hip: standing 1104 px, lowest point of the dip at frame 45, top at frame 100
Left: five stick figures of the jumper seen from behind, at standing (frame 0), the bottom of the dip (45), takeoff (80), the top (100) and landing (124). Right: the hip midpoint and the lower ankle, in pixels above their standing level, against frame number; the ankle leaves the ground near frame 80 and returns near frame 124, while the hip dips, rises and falls.

Read the right panel from left to right. The hips sink in the dip, drive up, keep rising after the ankle leaves the ground near frame 80, peak, and fall back before the ankle lands near frame

  1. The hips start rising long before takeoff, so the rise of the hips is not all flight. The

ankle trace is not flat before takeoff either: it drifts up by 20 to 50 pixels as the hand-held camera moves and the heel comes up, so a fixed height line on the ankle would open the flight too early (Section 1.3.3).

Step through the clip frame by frame in the viewer below. It draws the same table at the capture rate.

Loading the keypoint table…

Step 4 · Cleanse: rules first, then the data

Write the rules before applying them (Section 4.3), keep the raw table untouched, and log how many values each rule changes. Two rules are enough here:

  1. A keypoint with confidence below 0.5 is set to missing. The hidden face goes; the joints this study uses stay.
  2. Repeated frames are flagged, not deleted. Deleting them would change every frame number and every time after them; a flag keeps the record and lets each method decide.
PythonStep 4 · Two rules, a change log and a clean copy

Show the expected result without running
                    rule   field  values_set_missing
        confidence < 0.5    nose                 179
        confidence < 0.5   l_eye                 189
        confidence < 0.5   r_eye                 185
        confidence < 0.5   l_ear                  11
        confidence < 0.5   r_ear                   8
        confidence < 0.5 l_wrist                  14
        confidence < 0.5 r_wrist                  20
repeat flag (diff < 0.5)   frame                   0
frames flagged as repeats: 32 (none deleted)

Only face points and a few far-side arm points were removed. Now the three methods.

Method 1 · Count the frames in the air

The book's hand count of this clip, stepping through it frame by frame, put takeoff at frame 80 (the shoes first show above the grass) and landing at frame 124 (the first shoe disappears into it again). Print the lower ankle's height around those frames to see the same events in the table. Then turn the count into a height with h = g t² / 8, three ways: the right clock, the file's clock, and the right clock with the repeated frames left out.

PythonMethod 1 · Flight time from a frame count

Type a prediction to enable Run.

Show the expected result without running
ankle above standing (px), frames 77-83:  [54.0, 49.0, 49.0, 58.0, 78.0, 103.0, 137.0]
ankle above standing (px), frames 121-127: [143.0, 109.0, 64.0, 44.0, 30.0, 19.0, 19.0]
capture clock, 1/120 s a frame   44 frames -> t 0.367 s, h   16.5 cm
file clock, 1/30 s a frame       44 frames -> t 1.467 s, h  263.7 cm
repeats left out                 44 frames -> t 0.308 s, h   11.7 cm
if the count is 42 frames: 15.0 cm
if the count is 46 frames: 18.0 cm

In the table the ankle, already about 50 pixels up, climbs fast after frame 80 (58, 78, 103 pixels) and is back near that level at frame 124. On the capture clock, 44 frames are 0.367 s and the jump is 16.5 cm. On the file's clock the same count gives 264 cm, sixteen times too much. Grass hides the soles, so the count could be off by two frames either way, which moves the height between 15.0 and 18.0 cm.

The third line is a doubt the clip itself raises. Seven of the 44 frames in the air repeat the frame before. If the camera's 120 frames a second were each a distinct moment, the file holds only 37 distinct moments in the air and the flight was nearer 0.308 s (11.7 cm). This table cannot tell which reading is right; CS-3 uses the curve of the flight to test it.

Method 2 · The rise of the hips

A pose model gives positions in pixels. To turn the hips' rise into meters you need a scale. The jump app gets it from the athlete's stature, which you type in: standing upright, the distance from the eyes to the ankles is a fixed share of stature, so stature in pixels is that distance times 1.115 (jump/src/lib/metrics.ts). Here the eyes are hidden, so the ears, at about the same height, stand in for them, and the stature is the 1.70 m the book used. Both are assumptions.

PythonMethod 2 · Hip rise from keypoints, with a scale

Type a prediction to enable Run.

Show the expected result without running
scale 859 px per m (ear to ankle 1310 px)
hip rise, standing to top: 36.3 cm
hip rise, takeoff to top:  22.2 cm
  with a stature of 1.60 m: 20.9 cm
  with a stature of 1.80 m: 23.5 cm

Two different questions, two numbers. From standing to the top the hips rose 36.3 cm, but that includes the rise onto the toes before takeoff, like the wall-reach method of Section 1.3.1. From takeoff to the top, the quantity flight time measures, they rose 22.2 cm: more than the 16.5 cm from flight time, not less. The scale rests on a stature nobody measured (each 10 cm of stature moves the answer by about 1.3 cm) and on ears standing in for eyes, the camera was hand-held, and the hips are not the center of mass. Method 2 needs a scale; Method 1 needs only a clock.

Method 3 · The jump app's own result

The jump app ran on the same clip with the capture rate set to 120 and a stature of 1.70 m and wrote a text result. Its flight-time height comes from one function, jumpHeightFromFlight in jump/src/lib/flight-time.ts: h = g t² / 8 with g = 9.80665 m/s², the standard gravity. With a 17-keypoint model, whose lowest foot point is the ankle, it times takeoff and landing where the ankle's motion breaks most sharply, not where the ankle crosses a height line, because the ankle rises with the heel before the toes leave the ground (Section 1.3.3).

PythonMethod 3 · Read the app's result and repeat its formula

Show the expected result without running
{'height_cm': 43.0, 'flight_s': 0.367}
app flight 0.367 s -> g t²/8 = 16.5 cm (the app prints 16.5 cm derived)
app 'jump height' (hips, standing to top): 43.0 cm

The app's flight time is the hand count's, 0.367 s, and its formula gives the same 16.5 cm. Its headline "Jump height", 43.0 cm, is the hips' rise from standing to the top on its own scale, the same kind of number as Method 2's 36.3 cm, and just as dependent on a scale this clip cannot support. The book reached the same verdict: filmed from behind, hand-held and on grass, the clip breaks the app's capture instruction, so trust the flight time.

All the numbers on one line

PythonFive numbers for one jump

Show the expected result without running
hand count, flight time     16.5 cm
app, flight time            16.5 cm
hips, takeoff to top        22.2 cm
hips, standing to top       36.3 cm
app, 'jump height'          43.0 cm
Dot plot of five jump heights in centimeters for the same jump. Flight-time methods (hand count and the app) sit at 16.5 cm with a bar from 15.0 to 18.0 cm; hip rise from takeoff is 22.2 cm; hip rise from standing is 36.3 cm and the app's jump height 43.0 cm.

The two flight-time numbers agree, and the bar shows the counting uncertainty of two frames either way. The hip numbers spread far wider, and the two from standing measure a different thing. For this clip the flight time is the number to report.

Track it: start the athlete record

Every measurement from now on goes into one long table, one number per row, rows only ever added (the README's format, Appendix J). This study writes the first rows. The clip carries no date, so the date is left empty; on your own jump, fill it in.

PythonThe first rows of the athlete record

Show the expected result without running
test                metric  value unit  app                                            note
 cmj         flight_time_s  0.367    s            hand count 80-124 at 120 fps; +/-2 frames
 cmj jump_height_flight_cm 16.500   cm                         g t^2/8; course example clip
 cmj        jump_height_cm 43.000   cm jump app hip rise standing to top; scale not trusted

The answer. The jump is 16.5 ± 1.5 cm by flight time, if every file frame is 1/120 s; a change under 1.5 cm between two jumps measured this way is counting noise. One jump cannot show how much your jumps scatter from trial to trial, so film three next time (the challenge), and film them from the side, on a hard floor, with the phone still.

How good is the number?

The flight-time height has two kinds of error. Scatter: grass hides the soles, so takeoff and landing could each be off by a frame, and a count of 42 to 46 frames gives 15.0 to 18.0 cm, about ±1.5 cm. Bias: if each file frame is not 1/120 s, every height from this camera is off the same way; with the repeated frames left out, the same jump is 11.7 cm. A bias like that does not hide a change between two jumps filmed the same way, but it does matter when you compare with someone else's number. The hip-rise numbers carry a scale error on top: each 10 cm of assumed stature moves the takeoff-to-top rise by about 1.3 cm. The comparison with a reference is the app: its flight time and formula reproduce the hand count exactly (0.367 s, 16.5 cm).

Action card

Action card
Finding
Your jump was 16.5 ± 1.5 cm by flight time; a change of less than 1.5 cm between two jumps is noise.
Evidence
44 frames in the air at 120 frames per second, confirmed by the jump app's own flight time and formula; the hip-based heights depend on a scale this clip cannot give.
How sure
Moderate. One jump, a clip filmed from behind on grass, and a doubt about repeated frames that may make every height about 5 cm too large.
Action
Film three jumps from the side on a hard floor, phone still at waist height, at a normal-speed setting of 60 frames per second or more, and record the rate.
Test again
Repeat the same three jumps, same place and warm-up, before the jump block starts and again after six weeks.

Track it

This study writes the first rows of athlete-record.csv (Step "Track it"): test=cmj, metric=flight_time_s and metric=jump_height_flight_cm from the hand count, and metric=jump_height_cm from the jump app with its app_version. From now on, add one set of rows for every trial, with trial=1, 2, 3, the date, and the filming setup in protocol_version.

Open your athlete record

With your own data

Put your clip in local/ in place of jump2_120fps.mp4, change the capture rate if yours is not 120, and run the notebook from the top. Keep the clip in local/; share only the tables.

Check the AI

Asked "how high is the jump in jump2_120fps.mp4?", an assistant replied:

> The video runs at 30 fps. The feet leave the ground at frame 80 and land at frame 124, so the > flight lasts 44 / 30 = 1.47 s, and h = g t² / 8 = 9.81 × 1.47² / 8 = 2.64 m. That is an > excellent jump, well above average.

What is wrong with it?

The frame count is right; the clock is wrong. The header's 30 frames per second is the stored rate, not the 120 the camera recorded at, so the time is four times too long and the height sixteen times too large. The correct figure is 0.367 s and 16.5 cm. A range check would have caught it: no person rises 2.6 m.

Check yourself

  1. Why is the flight-time height trusted over the hip-rise height for this clip?

  2. The hips rose 36.3 cm from standing to the top but only 22.2 cm from takeoff to the top. Why the difference?

  3. A count of 46 frames at 120 frames per second gives what height, in centimeters?

    cm

  4. Every sixth frame of the file repeats the previous one. What did Step 4 do with those frames, and why?

0 of 4 answered · 0 right the first time

Challenge: Three of your own jumps

Film three countermovement jumps of your own (or a classmate's, with consent) to the jump app's capture instruction: from the side, whole body in frame, phone still on a tripod at waist height, on a hard floor, at 60 frames per second or more at normal speed. Run this study's notebook on each clip.

  1. Read each clip's header and state the capture rate you divided by, and check for repeated frames.
  2. Count the frames in the air by hand in the frame viewer, and run the jump app on the same clips.
  3. Compute the flight-time height of each jump, the mean, and the spread (largest minus smallest).
  4. Compute the hip rise from takeoff with your measured stature, and compare it with the flight-time height.
  5. Add the rows to your athlete-record.csv with the date and protocol.

Hand in

How it is judged

Hints

    The solution unlocks after you make an attempt. Comparing your own attempt with it is where the learning happens.

    The same method in another field

    Timing an event by counting samples, then checking the clock the samples were stored on, is the same problem as reading a data logger whose sample rate was set in one place and recorded in another. The Data-Driven Engineering course's page on video data starts from the same frame loop.

    Acknowledgements

    The clip is the course's example jump, processed locally; only keypoint tables and stick figures are published. Pose estimation uses Ultralytics YOLO (AGPL-3.0).

    References

    Built 2026-11-30 with Python packages numpy 2.5.5, pandas 3.1.1, matplotlib 3.11.2, ultralytics 8.4.219, cv2 5.1.0. In the browser the same code runs on Pyodide, so the last digit can differ.