A robust tool for analyzing weightlifting form (Squat, Deadlift) using computer vision. It uses MoveNet Thunder for high-accuracy tracking and Adaptive Geometry to correct for camera angles.
- High-Stability Tracking: Uses Google's MoveNet Thunder model (optimized for fitness) + Kalman Filtering to track limbs smoothly even during occlusions.
- Adaptive View Detection: Automatically detects if the video is Front, Side, or Oblique (e.g., 10 o'clock view).
- Perspective Correction: Mathematically "un-rotates" oblique views to provide accurate angles (e.g., true Squat Depth) regardless of camera placement.
- Physics-Based Smoothing: Uses velocity tracking to predict limb positions when they disappear behind weights.
- Phase Detection: Automatically identifies the Eccentric (down) and Concentric (up) phases of the lift.
- Clone the repo.
- Install dependencies:
pip install opencv-python numpy mediapipe tensorflow tensorflow-hub
Use the new MoveNet-based script for the most stable results and angle correction.
python src/pose_infer_movenet.py --video path/to/video.mp4 \
--out_overlay outputs/overlay.mp4 \
--out_json outputs/data.jsonAuto-Calibration Note: The system attempts to learn your body proportions to detect the camera angle. This requires the video to contain at least a few frames where you are facing the camera (e.g., at the start or end).
Manual Override: If your video is only from the side/oblique (no front view), you must specify the angle manually to avoid distortion:
# For a "10 o'clock" view (approx 60 degrees)
python src/pose_infer_movenet.py --video path/to/video.mp4 --yaw 600: Front View90: Side View
If you specifically need 3D world coordinates (X,Y,Z), you can use the older MediaPipe script. Note that this is less stable during occlusions.
python src/pose_infer_3d.py --video path/to/video.mp4The tool generates:
- Overlay Video: Visualizes the corrected skeleton, joint angles, and lift phase.
- JSON Data: Contains frame-by-frame keypoints (raw and corrected) and angle data for further analysis.
- Inference: MoveNet detects 17 keypoints.
- Kalman Filter: Predicts motion to smooth out jitter.
- Geometry Engine:
- Measures shoulder width to estimate body rotation.
- Projects points onto the ideal analysis plane (Sagittal for depth, Frontal for knees).
- Angle Engine: Calculates biomechanical angles (Hip Flexion, Knee Valgus, etc.).