Real-time AI cricket technique analysis in your browser β score your batting strokes and screen your bowling action against the ICC 15Β° elbow-extension guideline, using nothing but a webcam.
π Live: https://www.cricketcoach.online
The live view overlays a real-time skeleton on your camera feed and streams joint telemetry as you move. (Add a
docs/skeleton-overlay.gifhere to show it in motion.)
- 5 batting drills β cover drive, straight drive, pull shot, defensive block, flick shot β each scored against a biomechanically-authored ideal model via Dynamic Time Warping.
- ICC bowling action screen β an indicative elbow-extension check against the 15Β° Rule 11.1 guideline, with honest 2D-camera caveats (see Limitations).
- Hands-free auto-record β stand in your stance and the app detects stability, counts you down, records the shot, and analyses the follow-through automatically.
- Live skeleton overlay + telemetry β real-time joint angles (elbows, knees, spine tilt) with a ghost blueprint to align your stance.
- Left / right-handed support β the ideal model mirrors for left-handers.
- Runs in-browser β MediaPipe Pose executes on-device; your video never leaves your machine.
- Installable PWA β offline app-shell, add-to-home-screen.
ββββββββββββββββββββββββββββ Browser (on-device) ββββββββββββββββββββββββββββ
β β
β Webcam ββΆ MediaPipe Pose ββΆ 2D + 3D world landmarks ββΆ Canvas skeleton β
β β β
β βΌ β
β 33 joint coords / frame (no video) β
ββββββββββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββ
β POST /api/analyze-shot
βΌ
βββββββββββββββββββββββββββββ FastAPI backend ββββββββββββββββββββββββββββββββ
β extract angles ββΆ visibility gate ββΆ smooth ββΆ resample(50) ββΆ DTW vs ideal β
β ββΆ blend with motion/stance quality ββΆ score + coaching feedback β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Stack: React 19 + Vite (frontend, Vercel) Β· FastAPI (serverless on Vercel, or containerised on Render/Fly) Β· MediaPipe Pose (in-browser) Β· fastdtw + NumPy/SciPy scoring.
Frontend
npm install
npm run dev # http://localhost:5173 (proxies /api to :8000)Backend
cd api
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt # or requirements-full.txt for ball tracking
uvicorn index:app --reload --port 8000Tests
npm test # frontend smoke test (vitest)
cd api && python -m pytest tests -q
python -m eval.run_eval # scoring calibration harnessThe scorer is calibrated with a synthetic eval harness (api/eval/). Current results:
| Case | Score | Target |
|---|---|---|
| Ideal replay (all 5 shots) | 95β99 | β₯ 90 |
| Time-stretched ideal (0.5Γβ2Γ) | 97β100 | β₯ 85 |
| Noisy ideal (Β±3Β° jitter) | 98 | β₯ 75 |
| Sitting still | 5 | β€ 30 |
| Random flailing | 7 | β€ 30 |
Run python -m eval.run_eval from api/ to reproduce.
Bowling legality is an indicative screen, not an official verdict. A single 2D camera cannot match lab-grade 3D motion capture: elbow extension is defined in the arm's plane, but a webcam measures it in the image plane, and perspective foreshortening can add or remove tens of degrees. The app labels results as "likely legal / possible throw (indicative)", surfaces a disclaimer, and warns when you're filmed side-on (where the read is least reliable). Film front-on or at ~45Β°.
Batting scores also degrade when landmarks aren't well tracked; the response reports a tracking-quality percentage and the UI warns below 60%.
- Frontend: Vercel (
vercel.jsonβ SPA rewrite +/api/*βapi/index.py). - Backend (serverless): Vercel Python function. Ball tracking is disabled here (returns 501) since opencv/ultralytics are too large for serverless.
- Backend (container):
api/Dockerfile/render.yaml/api/fly.tomlinstallrequirements-full.txtand setENABLE_BALL_TRACKING=trueso/api/track-ballworks.
The bowling-action training script (api/train_action_model.py) produces a
bowling_model.pt; it is a research artifact not used at runtime and is not
tracked in git (attach it to a GitHub Release if needed).
- docs/ARCHITECTURE.md β system design & algorithms
- docs/API_REFERENCE.md β endpoint reference
- docs/DEPLOYMENT.md β production deployment
- docs/INDEX.md β full docs table of contents
MIT Β© 2026 Bilal Hasan
