Using MediaPipe Pose Estimation for Bike Fitting and Rotation Tracking

April 16, 2026 · Danny · MediaPipe Python Computer Vision

Bike fitting is one of those things that's part science, part art. A good fit can save watts, prevent injury, and shave minutes off a triathlon split. Most fitters rely on static photos, manual goniometers, or expensive motion capture setups. We wanted to see if we could do it with just a phone camera and YOLO.

We used Google's MediaPipe pose estimation model to build a pipeline that takes raw cycling video and outputs real-time joint angles, body position tracking, and pedal rotation counts. All you need is a single side-view camera angle.

How it works

You film a rider from the side, either on the road or a trainer. MediaPipe picks up 33 body keypoints per frame (shoulders, elbows, wrists, hips, knees, ankles, etc.) and from those we calculate the angles that actually matter for a bike fit:

  • Knee angle at bottom of pedal stroke (target is 140-150 degrees)
  • Hip angle, which is the torso-to-thigh angle that drives your aero position
  • Back angle, or how flat the torso sits relative to horizontal
  • Shoulder angle for reach to the handlebars
  • Elbow angle for arm bend and comfort

The result

Here's the model running on real road footage. Every frame gets keypoint detection, a skeleton overlay, and live angle calculations.

The skeleton tracks the rider through each pedal stroke. You can see the knee angle cycling between about 70 degrees at the top of the stroke and 145 at the bottom. The hip angle holds pretty steady around 45-50 degrees, which is typical for a triathlon position.

Tracking pedal rotations

The model also counts pedal rotations by tracking the knee's vertical position (in pixels) over time. As the rider pedals, the knee goes up and down in a repeating wave pattern. Each peak is the top of a pedal stroke. By smoothing the signal and detecting those peaks, we can count revolutions and calculate cadence directly from the video. No sensors needed.

Knee y-position over time with detected peaks

The blue line is the smoothed knee y-position over the ~17 second clip. The red dots mark detected peaks, which correspond to the top of each pedal stroke. The model found 28 revolutions, which works out to roughly 97 RPM. You can also see the rider's position shifting lower on the frame around the 7-8 second mark as the camera angle changes, but the peak detection still holds up.

The rotation counter and cadence readout are visible in the bottom-left of the video overlay. This is helpful for checking how body position changes at different cadences. If a rider's hip angle drops when they spin faster, that usually means the saddle is too high.

What this can flag

A typical bike fit captures one or two static frames. The advantage here is that you get angle data across the full pedal stroke, so you can see the range of motion rather than just a single snapshot.

A few things it picks up:

  • Knee overextension. If the knee angle at the bottom of the stroke is consistently over 150 degrees, the saddle is probably too high. Under 135 and it's too low.
  • Hip rock. If the hip angle swings more than 10 degrees through the pedal stroke, the rider is likely rocking side to side. That's usually a saddle height or cleat problem.
  • Aero position drift. On longer efforts, riders naturally sit up. Tracking back angle over time shows exactly how much position breaks down with fatigue.

The whole thing runs in real time on a laptop. No special hardware, just a side-view camera and a few seconds of video.


Built with Google MediaPipe.