PitchTrack DRS is a production-grade Android Cricket DRS (Decision Review System) and 3D Hawk-Eye coaching application built with Kotlin, Jetpack Compose (Material Design 3), CameraX, Firebase, and Clean MVVM architecture. It turns a phone mounted behind the bowler into a calibrated broadcast-grade analysis instrument: the user records or uploads a single delivery, aligns a four-corner perspective calibration of the pitch, and receives a tracked ball trajectory, real-world speed in km/h and mph, spin and swing metrics, an interactive 360-degree 3D Hawk-Eye replay, and a TV-broadcast-style LBW verdict card. Gemini-powered coaching then converts that telemetry into delivery-level and session-level tactical advice.
The audience is cricket bowlers and their coaches working at the nets, in indoor facilities, or on club grounds. They need precise, repeatable measurement of line, length, pace, and spin, and a clear LBW read they can trust and act on — not a toy. The product therefore pairs a real video frame with a calibrated 3D model of the same delivery, and presents numbers with broadcast-instrument clarity.
This document is the System Requirements Document requested by Muneeb Ahmad for the PitchTrack DRS project.
PitchTrack DRS is a single Android application (Kotlin, Jetpack Compose, Material Design 3) organized with Clean MVVM. It uses CameraX for live stationary recording, the Android Photo Picker for gallery video, Firebase Auth with Google Sign-In via Jetpack CredentialManager for identity, Firebase App Check initialized before Compose, Cloud Firestore for per-user persistence with real-time snapshot listeners, Firebase AI Logic (Gemini) for vision auto-detection and coaching, and a Compose 3D Canvas renderer (HawkEye3DCanvas) for the interactive Hawk-Eye viewer.
The app is delivered alongside a shared backend service (FastAPI) that hosts application APIs and domain modules, a MariaDB database for application-owned persistent data, a React frontend, and a LiteLLM gateway backed by PostgreSQL for model-provider calls. The provisioned infrastructure is authoritative for deployment; it does not add product capabilities beyond those specified.
Actors are the Bowler (records deliveries, reviews Hawk-Eye telemetry, corrects keypoints, uses AI coaching to plan the next ball) and the Coach (reviews session statistics, pitch map, and stump beehive across many deliveries, and uses session coaching summaries to set tactical adjustments). Both are active human personas; both authenticate with Google Sign-In.
Removed from scope
PitchTrack DRS is an Android-first, first-party application. All product surfaces — Landing, Sign In, Dashboard, Track & Record, Capture & Calibration, Sessions, 3D Hawk-Eye Review, and AI Bowling Coach — are owned and rendered by the application itself. Access is gated behind Google Sign-In using Jetpack CredentialManager and Firebase Auth; anonymous sign-in is not permitted. Landing and Sign In are anonymously reachable entry surfaces; every other destination requires an authenticated session. Firebase App Check is configured before Compose initialization so that backend and AI calls are attested.
All user data — BowlingSessions and DeliveryRecords — is stored in Cloud Firestore scoped per authenticated userId, with real-time snapshot listeners, create/delete/refine operations, and strict field validation. Offline and empty states are handled throughout, with a snackbar feedback host for transient results and errors.
The shared FastAPI backend, MariaDB, React frontend, LiteLLM gateway, and PostgreSQL are provisioned infrastructure supporting the application's APIs and model-provider calls. They do not introduce additional product behavior, destinations, or access rules. Gemini vision auto-detection and Gemini coaching are invoked through Firebase AI Logic as specified; the LiteLLM gateway supports the backend's model-provider calls.
Current scope covers the full delivery lifecycle: capture or upload, calibration, tracking, physics and speed, 3D review with LBW verdict, dashboard analytics, session management, and AI coaching. No future-horizon features are specified in the authoritative requirements.
aspectRatio(16/9) showing a fast bowler releasing a red cricket ball from a raised hand, a smooth single-bounce crimson Hawk-Eye trajectory down the pitch, and the ball smashing cleanly into the striker's stumps with wooden bails flying into the air.aspectRatio(16/9).screenToPitchGround, pitchGroundToScreen, height projection), snackbar feedback host.HawkEye3DCanvas with 3D stadium turf, pitch strip, popping/bowling/return creases, 3D wickets/targets with bails, translucent blue/red wicket-hitting zone box, ball animation replay slider/replay button, solid trajectory curve up to impact, and glowing dotted predicted path from impact into the stumps. 360-degree touch orbit (yaw & pitch drag), pinch-to-zoom, double-tap camera reset, preset angles (Bowler's End, Striker's End, Side-On, Top-Down), optional Transparent AR Video Overlay mode projected onto the recorded clip via the calibrated Homography3D. Frame-by-frame video scrubber with Previous Frame / Next Frame buttons and Release / Bounce / Impact keypoint selectors. Calibrated 3D LBW Simulator mode. TV-broadcast DRS overlay card: PITCHING (In Line / Outside Off / Outside Leg), IMPACT (In Line / Outside Off / Outside Leg / Umpire's Call), WICKETS (Hitting / Umpire's Call / Missing), FINAL VERDICT badge (OUT / NOT OUT / UMPIRE'S CALL), SPEED (km/h and mph side by side), spin (° / RPM), and swing metrics.FR-1 — Android app foundation. As a Bowler, I should use PitchTrack DRS as a production-grade Android app built with Kotlin, Jetpack Compose (Material Design 3), CameraX, Firebase, and Clean MVVM architecture, so that the product is delivered on the specified platform and stack. Provenance: explicit. Acceptance: app builds and runs on Android with Compose Material 3 UI and Clean MVVM layering.
FR-2 — Clean Light Coaching Studio palette. As a Bowler, I should see the Studio Alabaster background (#F7F9F8), white surfaces (#FFFFFF), soft borders (#DCE5E0), Pitch Emerald primary (#0F6B46), Hawk-Eye Indigo accent (#4F46E5), Ball Crimson (#DC2626), and Stump Gold/Amber (#F5B700 / #D97706) applied consistently, so that the interface reads as a precise coaching instrument. Provenance: explicit. Acceptance: tokens applied across all surfaces.
FR-3 — Adaptive edge-to-edge navigation. As a Bowler, I should get edge-to-edge layouts using WindowInsets.safeDrawing, with a bottom NavigationBar on compact phones (<600dp) and a side NavigationRail on tablets/foldables (>=600dp), so that navigation adapts to my device. Provenance: explicit. Acceptance: breakpoint at 600dp switches navigation component; insets respected.
FR-4 — Navigation destinations. As a Bowler, I should navigate to Dashboard, Track & Record (Capture & Calibration), Sessions, and full-screen 3D Hawk-Eye Review, so that I can reach every core workflow. Provenance: explicit. Acceptance: all four destinations reachable from the adaptive navigation.
FR-5 — Launcher icon and hero banner. As a Bowler, I should see a custom adaptive launcher icon and a 16:9 photorealistic stadium hero banner displayed unclipped at aspectRatio(16/9) on the sign-in screen and empty dashboard, showing a fast bowler releasing a red cricket ball from a raised hand, a smooth single-bounce crimson Hawk-Eye trajectory down the pitch, and the ball smashing cleanly into the striker's stumps with wooden bails flying into the air. Provenance: explicit. Acceptance: banner rendered unclipped at 16:9 on both surfaces; adaptive icon present.
FR-6 — Google Sign-In gate. As a Bowler, I should sign in with Google via Jetpack CredentialManager and Firebase Auth, with no anonymous sign-in, so that my data is protected. Provenance: explicit. Acceptance: unauthenticated users cannot reach protected destinations; anonymous sign-in unavailable.
FR-7 — App Check before Compose. As a Bowler, I should have Firebase App Check configured before Compose initialization, so that requests are attested. Provenance: explicit. Acceptance: App Check initialized in Application startup prior to Compose content.
FR-8 — Firestore persistence. As a Bowler, I should have BowlingSessions and DeliveryRecords stored in Cloud Firestore scoped per authenticated userId, with real-time snapshot listeners, create/delete/refine operations, and strict field validation, so that my data is durable and live. Provenance: explicit. Acceptance: records scoped to uid; listeners update UI; invalid fields rejected.
FR-9 — Offline, empty, and snackbar handling. As a Bowler, I should see offline and empty-state handling plus a snackbar feedback host, so that I understand system state. Provenance: explicit. Acceptance: offline indicator, empty states, and snackbar messages appear appropriately.
FR-10 — Live and gallery capture. As a Bowler, I should record live stationary video with CameraX VideoCapture using a manual Record/Stop button per individual delivery, or upload gallery video via the Android Photo Picker / PickVisualMedia, so that I can capture any delivery. Provenance: explicit. Acceptance: both paths produce a video for calibration.
FR-11 — Pitch and delivery settings. As a Bowler, I should choose pitch presets of 22 yards (20.12 m regulation), 16 yards (indoor/nets), or custom 10–30 yards, select bowler/batsman target objects (Wickets, Bricks, Blocks, Chairs) with real-world dimensions, bowler style (Pace/Seam or Spin), and ball color (Red Leather, White Ball, Tape/Tennis), so that calibration matches my setup. Provenance: explicit. Acceptance: custom yardage constrained to 10–30 yards; all options selectable.
FR-12 — Gemini auto-detect. As a Bowler, I should run Gemini multimodal vision auto-detection on a captured frame or uploaded video frame to detect the near (bowler) and far (striker) targets and return normalized coordinates, so that calibration starts from a good guess. Provenance: explicit. Acceptance: normalized coordinates returned and applied to pins.
FR-13 — 4-corner calibration overlay and loupe. As a Bowler, I should drag four corner pins (BL Bowler Left, BR Bowler Right, SL Striker Left, SR Striker Right), top height handles, and a 22-yard perspective pitch grid, with a live zoomed magnifier loupe while dragging and a "Lock Pitch" toggle that persists calibration across consecutive deliveries, so that alignment is pixel-accurate and repeatable. Provenance: explicit. Acceptance: loupe appears on drag; Lock Pitch retains calibration.
FR-14 — Homography computation. As a Bowler, I should have a true 3x3 perspective homography (screenToPitchGround, pitchGroundToScreen, height projection) computed from the four calibrated corners, mapping normalized pixels (u, v) to lateral meters (x) and pitch distance yards (z). Provenance: explicit. Acceptance: both directions and height projection available to tracking and 3D.
FR-15 — Frame-by-frame ball tracking. As a Bowler, I should have ProBallTracker sample video frames with exact MediaMetadataRetriever timestamps, restrict search within the calibrated homography corridor, and combine motion-delta foreground masking (suppressing stationary background, bowler arm clutter, batsman stance) with HSV/color filtering tuned to the selected ball type. Provenance: explicit. Acceptance: tracking confined to corridor; ball type affects filter.
FR-16 — RANSAC trajectory fitting. As a Bowler, I should have RANSAC parabolic trajectory fitting in calibrated 3D coordinates identify Release Point → Bounce Point (Pitching) → Pad/Bat Impact Point → Projected Stump Path. Provenance: explicit. Acceptance: all four stages identified.
FR-17 — Strict speed and metrics. As a Bowler, I should see speed in km/h and mph side by side derived strictly from calibrated 3D world distance between release/bounce/crease divided by exact elapsed video frame timestamps (never NaN, 0, or pixel guesswork), plus bounce distance (yards from bowler end), lateral pitching/impact offsets, spin angle (degrees) + spin RPM, swing factor, and tracking confidence. Provenance: explicit. Acceptance: no NaN/0 speeds; all metrics displayed.
FR-18 — Frame scrubber correction. As a Bowler, I should use a frame-by-frame video scrubber with Previous Frame / Next Frame buttons and Release / Bounce / Impact keypoint selectors to tap directly on any frame to correct ball position and recalculate trajectory, speed, and LBW verdict from the calibrated homography and timestamps. Provenance: explicit. Acceptance: correction triggers recalculation.
FR-19 — LBW Simulator. As a Bowler, I should use a Calibrated 3D LBW Simulator mode to test deliveries directly from calibrated telemetry. Provenance: explicit. Acceptance: simulator runs from calibrated telemetry.
FR-20 — 3D viewer interaction. As a Bowler, I should use HawkEye3DCanvas with smooth 360-degree touch orbit (yaw & pitch drag), pinch-to-zoom, double-tap camera reset, and one-tap preset angles (Bowler's End, Striker's End, Side-On, Top-Down). Provenance: explicit. Acceptance: all gestures and presets work.
FR-21 — AR video overlay. As a Bowler, I should optionally enable a Transparent AR Video Overlay mode projected onto the recorded delivery clip via the calibrated Homography3D. Provenance: explicit. Acceptance: overlay aligns with clip.
FR-22 — 3D scene contents. As a Bowler, I should see 3D stadium turf, pitch strip, popping/bowling/return creases, 3D wickets/targets with bails, a translucent blue/red wicket-hitting zone box, a ball animation replay slider/replay button, a solid trajectory curve up to impact, and a glowing dotted predicted path from impact into the stumps. Provenance: explicit. Acceptance: all elements render.
FR-23 — Broadcast DRS overlay card. As a Bowler, I should see a TV-broadcast style DRS overlay card with PITCHING (In Line / Outside Off / Outside Leg), IMPACT (In Line / Outside Off / Outside Leg / Umpire's Call), WICKETS (Hitting / Umpire's Call / Missing), FINAL VERDICT badge (OUT / NOT OUT / UMPIRE'S CALL), SPEED (km/h and mph side by side), spin (° / RPM), and swing metrics. Provenance: explicit. Acceptance: all rows and badge present.
FR-24 — Dashboard analytics. As a Coach, I should see KPI cards (Avg Speed km/h & mph, Avg Spin RPM, Avg Swing, LBW Out %), a visual Pitch Map (bounce length & line heatmap), a Stump Beehive impact chart, filter chips (All, LBW Out, Fast >=70 mph, Spin), and tappable delivery history cards. Provenance: explicit. Acceptance: KPIs, charts, filters, and cards render and filter correctly.
FR-25 — Session management. As a Coach, I should create, switch, and delete bowling sessions with custom pitch yardage, target types, and bowler style, plus session-wide statistics. Provenance: explicit. Acceptance: create/switch/delete work; stats shown.
FR-26 — Gemini coaching. As a Bowler, I should receive streamed delivery-level coaching from Firebase AI Logic — Gemini analyzing telemetry plus up to 3 extracted delivery keyframes for line, length, execution, and next-ball tactical adjustment, and full-session 3-bullet coaching summaries. Provenance: explicit. Acceptance: streaming output; up to 3 keyframes; 3-bullet summary.
FR-27 — Identity continuity. As a Bowler, I should complete Google Sign-In before protected pages open, so that my sessions and deliveries remain bound to me. Provenance: required_inference. Acceptance: protected destinations require authenticated session.
FR-28 — User-scoped records. As a Bowler, I should have Firestore records scoped to my authenticated userId, so that my data is isolated. Provenance: required_inference. Acceptance: queries and writes scoped to uid.
The Bowler is the primary operator of PitchTrack DRS at the nets or in an indoor facility. They mount a phone behind the bowling crease, record each delivery, and use the calibrated Hawk-Eye analysis to understand exactly what the ball did: release point, bounce length, lateral line, pace in km/h and mph, spin angle and RPM, swing, and whether the delivery would have hit the stumps. Their primary goal is to correct line, length, and speed ball by ball and to plan the next delivery with tactical intent.
Distinct responsibilities: capturing live or gallery video per delivery; choosing pitch presets, targets, bowler style, and ball color; running Gemini auto-detect and aligning the four-corner calibration with the zoom loupe; locking the pitch across consecutive deliveries; reviewing the 3D Hawk-Eye scene and DRS verdict card; scrubbing frames and correcting Release/Bounce/Impact keypoints to recalculate trajectory, speed, and LBW verdict; running the LBW Simulator; and requesting delivery-level coaching.
Inputs and decisions: which delivery to record, which calibration corners are correct, whether to lock the pitch, whether a keypoint correction is needed, and which coaching advice to act on. They interact with the Coach through shared sessions and session statistics. Observable success: a trustworthy speed reading, a clear verdict, and coaching that names a concrete next-ball adjustment.
The Coach works across many deliveries and sessions rather than a single ball. They use the Dashboard's KPI cards, pitch map heatmap, and stump beehive to see patterns in a bowler's line, length, pace, and spin over a session, and they use the AI Bowling Coach's 3-bullet session summaries to set tactical adjustments.
Distinct responsibilities: reviewing session-wide statistics; interpreting the pitch map and stump beehive across deliveries; creating, switching, and deleting sessions with the right pitch yardage, target types, and bowler style; applying filter chips (All, LBW Out, Fast >=70 mph, Spin) to isolate the deliveries that matter; and requesting full-session coaching summaries.
Inputs and decisions: which session to review, which filter to apply, and which tactical change to recommend. They interact with the Bowler through the shared session record and coaching output. Observable success: a session summary that identifies the dominant pattern and a concrete tactical recommendation the Bowler can execute.
aspectRatio(16/9), the headline "See the ball. Prove the verdict.", and the subline "Calibrate the pitch, track each delivery, and read the LBW call in 3D."screenToPitchGround, pitchGroundToScreen, height projection).HawkEye3DCanvas with yaw/pitch drag, pinches to zoom, double-taps to reset, and taps preset angles (Bowler's End, Striker's End, Side-On, Top-Down); they optionally enable the Transparent AR Video Overlay.The creative direction is Split craft after Adham Dannaway: a precise broadcast instrument, not a toy, pairing a real video frame with a calibrated 3D model of the same delivery.
#F7F9F8.#FFFFFF for every card.#0F241C.#0F6B46 — primary actions and verdict OUT.#4F46E5 — the 3D and code half only.#DCE5E0.#DC2626 — the ball and NOT OUT.#F5B700 and #D97706 — bails, stump zones, and UMPIRE'S CALL.The public entry is a vertical split hero: a full-width 16:9 stadium photo sits unclipped at the top. The left half shows the bowler frame in light; the right half is a dark ink panel with the 3D stump render, separated by a hairline seam. The headline "See the ball. Prove the verdict." spans both halves in Space Grotesk at 56px desktop and 36px mobile, with the subline "Calibrate the pitch, track each delivery, and read the LBW call in 3D." beneath it. The "Sign in with Google" button sits under the headline on the left in Pitch Emerald. A dark code-style panel shows the homography matrix and live speed in JetBrains Mono beside the 3D viewer, and the DRS verdict card uses three stacked ruled rows with tabular numerals and one colour-coded badge. The concept recomposes only accepted content and controls.
Interaction Model: Animated Motion Tempo: restrained Hero Dimensionality: layered_2d
Landing Hero Motion Brief
aspectRatio.WindowInsets.safeDrawing; navigation adapts at the 600dp breakpoint.HawkEye3DCanvas).screenToPitchGround, pitchGroundToScreen, height projection) mapping normalized pixels to real-world lateral meters and pitch yards.
PitchTrack DRS — calibrate the pitch, track each delivery, and read the LBW call in 3D.
# screen → pitch ground homography = 'screenToPitchGround' pitch = 22 yd · 20.12 m
h = [ 1.2840 -0.0630 -142.5070 0.0410 0.9720 210.3380 0.0004 -0.0011 1.0000 ]
Google sign-in keeps every session and delivery in your own coaching workspace.

PitchTrack DRS — calibrate the pitch, track each delivery, and read the LBW call in 3D.
# screen → pitch ground homography = 'screenToPitchGround' pitch = 22 yd · 20.12 m
h = [ 1.2840 -0.0630 -142.5070 0.0410 0.9720 210.3380 0.0004 -0.0011 1.0000 ]
Google sign-in keeps every session and delivery in your own coaching workspace.
No comments yet. Be the first!