Adaptive ball recovery · TrackNetV2 comparison · downstream modules

Search in a player-guided crop.
Continue locally at finer detail.

This thesis tests whether a MobileNetV4-based TrackNet can retain ball-detection quality at substantially lower raw model-call cost. Four task-specific checkpoints are compared; the selected MobileNetV4 Search and Tight checkpoints then feed frame-linked coordinates into player, pose, event, and optional court modules.

Clearly labelled schematic flow from player-guided Search context to a measured validation peak and a source-frame ball coordinate
Processing flow is schematic; the validation peak is measured. The panels are not consecutive runtime frames.
Schematic flow · measured peak
02
ball-tracking tasks
04
compared checkpoints
4.45×
raw Search model throughput
3.45×
raw Tight model throughput

Six modules · one source-frame index

All module outputs share one source-frame index.

The ball may occupy only a few pixels; a player spans hundreds. Court geometry changes slowly, while a hit can only be identified across time. The RallyTrace pipeline assigns each signal to a specialized module and returns every result to one source-frame timeline.

  1. 01

    Index video

    Preserve the absolute frame index and derive display time from the source frame rate.

    Runtime scope
  2. 02

    Find players

    Rank detections and retain up to two tennis-relevant player regions.

    Player context
  3. 03

    Recover ball

    Acquire the ball in Search mode, then continue locally in Tight mode.

    Search / Tight
  4. 04

    Read movement

    RTMPose estimates 17 COCO body points for each retained player.

    Pose timeline
  5. 05

    Infer events

    Fuse ball, player-box and pose evidence across a 25-frame window.

    Temporal events
  6. 06

    Register court

    An optional parallel branch projects a consistent court template into the image.

    Court geometry

Shared source-frame timeline Absolute frame index · ball coordinate and confidence · recovery state · up to two player boxes · pose provenance and quality · event probabilities · optional court geometry

Player-guided Search · position-guided Tight

Search uses a 9:16 crop.
Tight uses a 25%-height local crop.

Rather than repeatedly shrinking the entire 16:9 image, the recovery pipeline first searches a portrait region positioned from the players. After a reliable peak is found, Tight mode follows the ball in a smaller local crop with finer source-pixel mapping.

Mode 02

Tight

25%-height local crop
Three local Tight validation crops with a magnified tennis ball, magenta prediction peaks and target rings
The Tight validation crop is generated around a known ball position with training-style crop jitter. It demonstrates the local detection task—not a before/after pair from one runtime transition.

The following three-frame block uses a crop only 25% of the source height, centred on the last trusted ball position. Removing background lets the lighter model operate at nearly source-pixel detail.

1080p source crop (W × H)
≈ 152 × 270 px
Model tensor (W × H)
144 × 256
Linear source-pixel span per heatmap step
≈ 1.05
75%

fewer model-input pixels than Search

≈2×

finer source-pixel mapping in this 1080p example

Why it matters: a distant tennis ball may span only a few blurred pixels. Reducing the full frame too early can merge that evidence with a court line or the background. Cropping before resizing preserves local detail without the cost of processing the complete frame at high resolution.

Diagram comparing the large Search crop and local Tight crop, including their source-to-model pixel mapping Open full-size diagram in a new tab
Search: ≈2.11 source pixels per heatmap step; Tight: ≈1.05. Values follow the implemented crop rules for a 1920 × 1080 source.
State diagram showing blockwise switching between Search and Tight after visible peaks or sustained loss Open full-size diagram in a new tab
One model processes each three-frame block. Its ordered measurements update recovery state; any state change selects the model for the next block.
Controlled comparison · held-out games 30 and 31

Compare MobileNetV4 TrackNet with TrackNetV2 in both recovery modes.

Can the modified MobileNetV4 TrackNet retain the reference model's detection quality while reducing inference cost in both recovery modes? Held-out accuracy and raw model throughput answer complementary parts of that question and are measured separately.

Training / validation
9,684 / 1,030 windows
games 30 and 31 held out
Within each task
same crops and metrics
3,090 validation heatmaps
Checkpoint reporting
one saved checkpoint
not a mix of per-column maxima
Throughput
raw TensorRT FP16
RTX 4060 · batch 1 · GPU-resident
Task 02 · local continuation

Tight / Crop · W × H: 144 × 256

Checkpoint selection criterion: peak score.

Complete · both studies 200/200 epochs

Training: both Tight models completed 200/200 epochs with AMP.

3.45×raw model throughput

Small detection trade-off. TrackNetV2 leads by 0.0039 F1; the modified model retains 99.6% of that F1 with 3.45× raw model throughput.

Modified TrackNetMobileNetV4 · 1.40M parameters
1,883.35 calls/s
TrackNetV2reference · 11.33M parameters
545.99 calls/s
Tight validation at each model's peak-score-selected checkpoint
MetricMobileNetV4 TrackNetTrackNetV2
Selected epoch3126
F1 ↑0.94650.9504
Precision ↑0.96460.9768
Recall ↑0.92910.9254
Miss rate ↓0.04080.0557
Mean source-frame error ↓2.29 px1.89 px
Peak score ↑0.92190.9299
Selected checkpoints

Search: +0.0012 F1 at 4.45× raw throughput. Tight: −0.0039 F1 at 3.45×.

Search improves coordinate precision and raw throughput without reducing F1 at the selected checkpoints. Tight trades 0.0039 F1 for 3.45× raw throughput. These complementary results motivate the two task-specific MobileNetV4 checkpoints used by adaptive recovery.

Protocol and interpretation limits

Within each Search or Tight pair, accuracy uses the same loader, labels, held-out games, crop distribution, heatmap target, WBCE and peak metrics. Search counts a prediction as correct within 4 px and near within 5 px; Tight uses 5 px and 7 px. Mean source-frame error covers every visible sample with a returned peak—including far-away wrong peaks—and is not restricted to correct detections. The modified models use an ImageNet-pretrained MobileNetV4 backbone, while the pinned third-party TrackNetV2 PyTorch reproduction starts from random initialization. This is an operational checkpoint comparison, not a controlled from-scratch topology ablation.

The throughput experiment is separate: five trials of 5,000 GPU-resident TensorRT FP16 calls after 1,000 warm-ups on an RTX 4060. Decode, crop, resize, transfers, peak extraction, state logic, drawing and encoding are excluded. One call emits three heatmaps; calls/s is not end-to-end video FPS. TrackNetV2 Search remains an interim accuracy result until its 200-epoch FP32 run finishes.

The dense TrackNetV2 throughput engines use deterministic initialization rather than the trained accuracy checkpoints; structured sparsity is disabled, so weight values do not alter the dense operator topology being timed. Their H/W order is transposed relative to the modified portrait tensors while retaining the same pixel count.

From three frames to three coordinates

Each input frame receives its own heatmap.

Three consecutive RGB frames form a nine-channel tensor. TrackNet returns three single-channel probability maps—not predicted future frames. Output position one, two or three corresponds to the input frame at the same position.

Three RGB frames stacked into a nine-channel tensor, processed by TrackNet and returned as three aligned heatmaps Open full-size diagram in a new tab
The coloured fields explain tensor alignment. The measured validation artifacts store peak overlays rather than the complete raw probability arrays.
Measured validation output

Inspect the selected peak without smoothing

Nearest-neighbour enlargement exposes the exact model-input pixels beneath two selected-checkpoint validation examples. The Search and Tight examples are independent tasks, not a runtime transition.

01

Reduce each map to one peak

GPU argmax reduces each heatmap to its global maximum. The flat index becomes x and y; the maximum value becomes the confidence score.

02

Apply the visibility threshold

A score of at least 0.5 marks the candidate visible. A lower peak may still be exported, but it cannot steer recovery as a trusted ball position.

03

Map to the source

The active crop transform maps the coordinate into the original video frame for visualization and downstream modules.

GPU peak decoding from dense heatmaps through global argmax and threshold to source-frame coordinates Open full-size diagram in a new tab
Dense maps remain on the GPU. In C++, each call sends only three 12-byte peak records—int32 x, int32 y and float32 score—to CPU state logic: 36 bytes in total. The PT runner transfers the same payload size as three float32 triples.

16-channel temporal input · full-resolution detail branch

Five-scale MobileNetV4 features feed a full-resolution output path.

The model concatenates temporal-difference channels with RGB input, extracts features at strides 2–32 through MobileNetV4 Conv Small, and fuses a full-resolution detail path before sigmoid. The checkpoint study compares complete models; it does not isolate the effect of each component.

Modified TrackNet topology from three RGB frames through motion features, MobileNetV4 multi-scale features, decoder and detail path to three heatmaps Open full-size diagram in a new tab
Schematic topology shared by the active Search and Tight variants. Block size represents information flow, not measured execution time or parameter count.
Temporal input

16 channels encode appearance and change

Nine RGB channels are augmented with signed temporal direction, absolute motion and an acceleration-like difference before a lightweight adapter feeds the backbone.

Multi-scale context

The decoder fuses strides 2, 4, 8, 16, and 32

MobileNetV4 features at strides 2, 4, 8, 16 and 32 let the decoder combine fine spatial evidence with wider scene context.

Detail branch

A full-resolution path reaches the output

A separate branch preserves the centre frame, temporal differences and edges, then fuses its logits with the main prediction immediately before sigmoid.

Open the motion-channel breakdown
Breakdown of the exact 16-channel temporal representation used before the TrackNet backbone Open full-size diagram in a new tab

Search uses 96 lateral channels and a BiFPN-like fusion block. Tight uses 64 channels and a lighter top-down path. They are separate checkpoints trained on different crop distributions, not one checkpoint resized at runtime.

Validation beyond ball tracking

Keep ball, detector, event, and court metrics separate.

The ball-model experiment is the primary controlled comparison. Player, event and court modules answer different questions under different protocols, so their results are reported separately rather than combined into an artificial system score.

Player detector0.828

mAP50–95

One-class YOLO11n validation measures player detection, not persistent identity.

Event fusion0.984 · 0.919 · 0.940

F1: bounce · upper hit · lower hit

Predicted and labelled events match within a ±6-frame tolerance.

Court detector0.762

mAP50–95

This measures anchor-box detection, not point localization or homography accuracy.

YOLO11n keyframes · RTMPose on player crops

Player boxes define crops.
Pose keypoints supply body-motion features.

A fine-tuned one-class YOLO11n supplies up to two tennis-relevant boxes. The boxes position the Search crop; in the extended pipeline, enlarged player crops also feed RTMPose for 17 COCO body points. Keyframe inference limits cost, while explicit interpolation fills the shared timeline.

01

Retain up to two relevant players

Ranked boxes shape the portrait Search region and the smaller pose crops. The labels upper and lower refer to vertical image position, not persistent identity.

02

Crop before estimating pose

Each player box is enlarged and padded to 192 × 256 px (W × H). Up to two crops share one inference batch, avoiding full-court input to the keypoint model.

03

Record how each pose was obtained

Each pose stores whether it was measured, interpolated or carried from an endpoint, together with confidence and age. Reconstructed frames remain distinguishable from direct measurements.

Five-frame player-crop sequence with distinct measured endpoint poses, interpolated intermediate joint positions and explicit provenance labels
Measured and reconstructed poses remain distinguishable. Solid endpoint observations and translucent intermediate joints illustrate the default four-frame cadence; every stored pose retains source, age and confidence.

25-frame input · three independent event scores

Classify bounces and player hits from ball, box, and pose features.

Wrist motion alone does not establish contact, and a trajectory change may indicate a bounce, racket contact or tracking error. The fusion model therefore evaluates ball, player-box and pose evidence jointly across 25 frames.

12 frames beforecentre12 frames after
Measured PT validation outputSelected held-out lower-player contact

game1000 · source frame 120 · centres 108–132

Selected held-out validation example · game1000, frame 120. Each point is a measured PT checkpoint output for one consecutive window centre; every score uses its own ±12-frame context. Only the lower-hit channel crosses its class threshold; temporal suppression retains its maximum at frame 120.

175 features / frame

Ball, body and reliability

Each frame contributes ball position and confidence, recovery state, two boxes, 12 selected body joints per player, ball-to-arm distances and trajectory dynamics.

3 independent outputs

Bounce · upper hit · lower hit

Each class has an independent probability and decision threshold, so a frame is not forced into exactly one event class.

Temporal peak selection

Consolidate neighbouring peaks

Per class, the strongest local score is retained and weaker neighbours within ten frames are suppressed. The 12 future frames require approximately 200 ms look-ahead at 60 fps.

Four detected anchors · one 3 × 3 homography

Project a fixed court template onto the camera frame.

A separate YOLO11n checkpoint detects two upper and two lower service-area anchors. Their centres determine a projective homography that maps a known tennis-court template into the camera image.

Tennis video with four detected service-field anchors and a complete projected court line model
Four detected anchors generate 18 projected points and 11 line segments through geometry; the network does not predict each court line independently.
01

Detect anchors

Predict boxes around four service-area reference points.

02

Validate geometry

Remove duplicates and reject implausible point ordering.

03

Solve the homography

A 3 × 3 transform relates normalized court and image planes.

04

Project the template

Generate every point and line from the smoothed, cached anchors.

Rule-based post-processing · no additional model

Pair each contact peak with the next valid projected bounce.

The browser performs this post-inference pairing with explicit timing and geometry rules. No additional trained model is involved.

  1. 01

    Consolidate contact peaks

    Group hit candidates within 0.18 s and retain the highest probability.

  2. 02

    Find the next qualifying bounce

    Search forward for at most 3 s, stop before the next separated hit, and require at least 0.12 s flight time, ball score ≥ 0.5 and a valid court projection.

  3. 03

    Project contact and landing

    At contact, use a smoothed player-position proxy with the ball as fallback; at bounce, use the projected ball position. Retain player role and absolute frame indices.

  4. 04

    Derive review values

    Classify in/out against singles geometry with a 0.12 m line tolerance, measure planar span and divide a straight-line path estimate by flight time.

Crop · batch · reduce on GPU · bound queues

Four implementation choices reduce per-frame work.

These choices bound implementation work around the models. Only raw model-call throughput is quantified below; the four cards describe implementation decisions, not separately measured speedups.

Spatial focus

Crop before resizing

Search removes low-value side context; Tight preserves detail only around the trusted ball position.

Temporal reuse

Return three heatmaps per call

TrackNet returns three aligned measurements, while player and pose inference run sparsely.

Data locality

Reduce before transfer

Heatmaps remain on the GPU; compact coordinates and confidence update recovery state.

Bounded flow

Reuse buffers and bound queues

Decode, player/pose and ball stages can overlap without accumulating an unlimited backlog.

Two-panel comparison of raw TensorRT FP16 calls per second for the modified MobileNetV4 TrackNet and TrackNetV2 in Search and Tight tasks Open full-size benchmark in a new tab
Raw model throughput, not video FPS. Each panel compares equal-pixel inputs on the same RTX 4060; held-out accuracy is reported separately in the four-checkpoint study.
Measurement boundary for raw throughput

The RTX 4060 benchmark measures serial, GPU-resident TensorRT FP16 model calls: 619.79 versus 139.35 calls/s for Search and 1,883.35 versus 545.99 calls/s for Tight. Each call returns three heatmaps. Decode, crop, resize, transfers, peak extraction, recovery logic, drawing and encoding are outside the timed region. The values isolate architecture cost and must not be interpreted as preview or end-to-end video FPS. Review throughput beside accuracy ↑

Public Python preview · extended C++ pipeline

Python covers recovery and court projection.
C++ adds pose and events.

Both implementations share adaptive Search/Tight recovery, but they are not feature-identical. The distinction below defines exactly which claims belong to the public preview and which belong to the extended research pipeline.

Runnable preview · PyTorch checkpoints

Python PT runner

Loads PyTorch checkpoints directly and reproduces the visual ball-recovery path without ONNX or TensorRT.

  • Search and Tight TrackNet
  • YOLO11n player localization
  • Recovery state, crop and ball trail
  • Optional court anchors and homography
  • Annotated MP4, frame CSV and run JSON

Excluded from this runner: native RTMPose and the event timeline. The archive contains no PT pose checkpoint, so this implementation cannot construct the pose stream required by the event models.

Extended C++ research path

Performance-oriented C++ path

Adds human-motion and temporal-event modules to a deployment stack designed for high-throughput coordinate recovery.

  • CUDA/NVDEC frame path and peak reduction
  • Sparse YOLO11n player timeline
  • RTMPose with 17 COCO points
  • Classic pose-hit or ball-pose event model
  • Bounce, upper-hit and lower-hit probabilities

Deployment distinction: this historical path uses TensorRT engines; the public preview deliberately executes PT checkpoints directly.

Precomputed, frame-aligned output

Review ball tracks, event scores, and court projection against video.

The RallyTrace demo synchronizes trajectories, event candidates, and court projection with the source video and absolute frame index.

Open match demo Back to thesis overview