DysTest

Thin-Plate Spline Gaze Calibration with Adaptive Per-Point Regularization

Mapping Iris Geometry to Screen Coordinates Without Dedicated Eye-Tracking Hardware

Uttam Panda, Christian Boer · Whitepaper · 2026

Webcam-based gaze estimation requires a calibration step that maps a noisy, person-specific iris-offset signal onto screen coordinates. We present a sixteen-point calibration procedure that fits a Thin-Plate Spline (TPS) — a radial-basis interpolant minimising bending energy — over normalised iris-offset features, with head-pose and post-validation affine correction layers applied on top. The central methodological contribution is an adaptive, per-point regularisation scheme: each calibration point is assigned a regularisation weight as a function of its sample count and within-point dispersion, so that noisy fixations are smoothed rather than interpolated exactly. We show, using empirical calibration logs, that naive formulations of this weighting allow a high-sample-count noisy point to be trusted more than a low-sample-count clean point, and we derive the corrected formulation that removes this failure mode. We further document the proximity-gated sample-collection procedure that determines which frames are accepted into the training set, and its dependence on a per-user neutral-gaze baseline.

1. Introduction

Webcam-based gaze estimation has no access to the corneal-reflection geometry that dedicated infrared eye trackers use to recover gaze direction directly. What is available — a normalised, eye-width-scaled iris-offset signal derived from RGB face-mesh landmarks — is a noisy, individual, and non-linear function of true gaze direction, shaped by each subject's eye anatomy, camera angle, and seating distance. A calibration procedure that learns the mapping from this signal to screen coordinates for the current subject and session is therefore not an optional refinement; it is the mechanism by which the platform acquires any gaze-estimation capability at all. This paper specifies that procedure: a sixteen-point calibration grid fitted with a Thin-Plate Spline (TPS), with a regularisation scheme that adapts to the measured quality of each calibration point rather than applying one smoothing strength uniformly.

2. The Iris-Offset Feature

For each accepted video frame, the platform computes a two-dimensional feature (gx, gy): the binocular average of each eye's iris-centre displacement from its own eye-corner midpoint, normalised by half the eye's width, then rotated into an upright-face frame by the head-roll correction described in Inter-Pupillary Distance–Based Depth Estimation (this series). This feature is approximately linear in gaze angle only over a narrow range and only for a fixed head pose; it is the calibration model's task to learn the (non-linear, subject-specific) function from this feature to normalised screen coordinates (targetX, targetY).

3. Thin-Plate Spline Fitting

3.1 Why a spline rather than a low-order polynomial

A low-order polynomial fit (the approach used by early webcam gaze-tracking prototypes) cannot simultaneously fit a sixteen-point grid with the curvature that anatomical and optical non-linearity actually produces without either underfitting the centre of the screen or oscillating at the edges. A Thin-Plate Spline avoids this by construction: it is the unique interpolant that passes through every training point exactly (in the zero-regularisation limit) while minimising integrated bending energy elsewhere, giving a smooth, well-behaved surface between calibration points without the global instability a high-order polynomial would introduce.

Figure 1. A regular grid of noisy iris-offset calibration samples (left) is warped by the fitted thin-plate spline onto the true screen-coordinate targets (right), bending most where the data demands it and staying smooth elsewhere.

3.2 The TPS system

Given n calibration points with normalised iris-offset coordinates (gx_i, gy_i) and screen targets t_i, the platform solves, independently for the X and Y screen coordinates, the linear system

[ K + ΛI    P ] [ w ]   [ t ]
[ Pᵀ        0 ] [ a ] = [ 0 ]

where K_ij = φ(‖(gx_i,gy_i) − (gx_j,gy_j)‖) is the TPS radial-basis kernel φ(r) = r²·log(r) (with φ(0) = 0 by convention), P is the design matrix [1, gx_i, gy_i] carrying the affine part of the fit, w are the per-point RBF weights, a = [a0, a1, a2] are the affine coefficients, and Λ is a diagonal regularisation matrix — one independent λ per calibration point, not a single global scalar — which is the focus of §4. Iris-offset coordinates are z-score normalised (zero mean, unit variance, computed across the active calibration points) before this system is assembled, so that the kernel's distance metric is not dominated by whichever axis happens to have larger raw magnitude.

3.3 Evaluating the fitted model

At inference time, a new iris-offset observation (gx, gy) is normalised with the same z-score parameters used at fit time, and the fitted surface is evaluated as

f(gx, gy) = a0 + a1·gx + a2·gy + Σ_i w_i · φ(‖(gx,gy) − (gx_i,gy_i)‖)

independently for the X and Y screen axes, with the result clamped to [0, 1] before any downstream correction layer (head-pose OLS correction, quick-affine recalibration, and post-validation affine correction, each applied in sequence) is applied.

4. Adaptive Per-Point Regularisation

4.1 The problem with uniform regularisation

At near-zero regularisation, a TPS interpolates its training points exactly. This is desirable when every training point is a clean, reliable measurement of the true target mapping, and catastrophic when one point is not: the surface will bend sharply to pass exactly through a noisy outlier, distorting the mapping in the surrounding region of the screen far more than the single bad observation should justify. Because calibration points vary substantially in collection quality — a child fidgeting during one of sixteen dots is the rule, not the exception — uniform regularisation forces an unfavourable global trade-off between fitting the clean majority of points tightly and not over-fitting the noisy minority.

4.2 Per-point quality signal

Each calibration point accumulates two quality signals during its collection window: the number of accepted iris-offset samples (accepted, capped in practice around 30 per point under the platform's early-accept logic for cooperative subjects), and the standard deviation of the iris-offset signal across those accepted samples on each axis (sdX, sdY) — a direct measure of how much the subject's gaze drifted while a single point was nominally being fixated.

4.3 Regularisation formula

The per-point regularisation weight is computed as:

sampleQuality = min(accepted / 30, 1)
sdPenalty     = min((sdX + sdY) / (2 × 0.06), 1)
q             = sampleQuality × (1 − sdPenalty)
λ             = 0.05 + (1 − q) × (0.2 − 0.05)

so that λ ranges from 0.05 (high sample count, low dispersion — trust this point near-exactly) to 0.2 (forced/timed-out points with zero accepted samples, or any point at the dispersion ceiling — smooth this point's contribution heavily). Forced points (collected with zero accepted samples after a collection-window timeout) are assigned λ = 0.2 directly, bypassing the formula, since there is no sample-based quality signal to compute for them.

4.4 A documented failure mode and its correction

An earlier formulation of this scheme applied only half the dispersion penalty (q = sampleQuality × (1 − sdPenalty × 0.5)), reasoning that sample count alone should partially compensate for dispersion. In production calibration logs this allowed a clinically meaningful failure mode: a corner calibration point collected with double the typical sample count (30 vs. the usual 15, via the platform's early-accept extension) but with iris-offset dispersion roughly five times that of its neighbours — sdX ≈ 0.036 against neighbouring points' 0.002–0.011 — received λ = 0.0826, a lower (more trusted) regularisation weight than a clean neighbouring point with half the samples (λ = 0.1303). The noisiest point in the calibration set was, by construction, the one the spline was instructed to fit most exactly. Because a Thin-Plate Spline is a global interpolant, the resulting distortion was not confined to the immediate vicinity of the bad point: validation error at held-out points in the same screen region rose into the 250–300-pixel range, well above the ~90–150-pixel error typical of a well-collected sixteen-point calibration. Removing the × 0.5 attenuation (§4.3, current formula) corrects the ordering for this case while leaving sample count with a smaller, still-deliberate independent influence — a point with very few samples is genuinely less certain even at low measured dispersion, since dispersion itself is poorly estimated from few observations.

5. Sample Collection Gating

A sample is only added to a calibration point's accumulating buffer when a proximity gate judges the subject to currently be fixating that point, using a fallback gaze estimate computed directly from iris geometry (deliberately not the partially-trained TPS model itself, to avoid the circularity of needing an accurate model to collect the data that produces one). For points near screen centre, the gate is a simple proximity circle around the fallback estimate; for outer points, where the limited range of eye rotation means a subject's gaze may satisfy only one screen axis strongly, the gate accepts a frame if either the horizontal or vertical component of the fallback estimate is on the correct side of centre — an OR rather than an AND condition — since requiring both simultaneously was found to leave outer corner points starved of samples for subjects who compensate with head movement on one axis and eye movement on the other.

6. Multi-Attempt Pooling on Redo

6.1 Motivation

When the post-calibration validation (companion paper, §5) reports a "Fair" or "Borderline" accuracy rating, the subject is offered a "Redo calibration" action. Prior to this scheme, a redo discarded the first attempt's sixteen observations unconditionally and rebuilt the model from the second attempt alone — even when the first attempt's data was largely good and only one or two dots were noisy. Since §3.3's TPS evaluation and the per-point regularisation in §4 already exist specifically to tolerate a minority of noisy points without corrupting the rest of the surface, discarding an entire attempt over a handful of bad points wastes usable data the subject already provided.

6.2 Pooling mechanism

A redo retains, rather than clears, the previous attempt's sixteen CalibrationObservation records and their associated per-point quality records. The new attempt's sixteen points are collected as normal and appended to the same arrays. buildCalibrationModel's per-dot deduplication groups all observations by calibration-point id regardless of which attempt produced them, and combines each point's iris-offset coordinates by inverse-dispersion weighting rather than a plain median or mean: each attempt's observation for a given point is weighted by 1 / (irisSDx² + irisSDy²), so a cleanly-collected observation dominates a noisy one in proportion to how much cleaner it measurably is.

This distinction matters specifically because a median of exactly two values is just their average — it provides no outlier rejection at n = 2, the common case for a single redo. A point collected with a 305 px-equivalent error in one attempt and a 49 px-equivalent error in another would, under plain averaging, still pull the combined estimate to roughly the midpoint between them — measurably worse than the good attempt alone. Inverse-dispersion weighting instead lets the low-dispersion attempt's coordinate dominate (in the worked numerical case below, a ~100:1 weight ratio for a 10× difference in dispersion), while still degrading gracefully to a plain average when neither attempt's collection of that point was meaningfully cleaner than the other's — there is no quality signal to prefer one observation in that case. The TPS still trains on exactly sixteen unique points regardless of how many attempts contributed to them, so model-fitting cost does not grow with redo count.

Per-point quality signals (§4.2) are aggregated the same way: accepted-sample counts are summed across attempts (more total evidence), and dispersion (sdX, sdY) is combined as a sample-count-weighted average, so a point's regularisation weight reflects the combined evidence from every attempt that touched it. A point forced by timeout with zero samples in one attempt but cleanly collected in another is treated as collected, not forced — the per-point record only counts as "forced" if every attempt that touched that point failed to collect any real data.

6.3 Head-pose consistency guard

Pooling is only safe when the subject's head position has not moved meaningfully between attempts, since §2 establishes that the iris-offset feature is a function of head pose as well as gaze angle — blending observations collected at two materially different head positions would corrupt the fitted surface rather than improve it. Before pooling, the platform compares the new attempt's mean (yaw, pitch) against the locked head-pose reference from the previous completed attempt (the same reference isHeadPositionDrifted uses to detect mid-assessment drift), using the same 12° Euclidean threshold. If the new attempt's head position has drifted past this threshold relative to the prior attempt, the prior attempt's observations are discarded and the model is built from the new attempt alone — falling back to the original (pre-pooling) behaviour rather than risking a worse model.

6.4 Worked example

Two genuinely observed validation outcomes from the same subject, redone moments apart:

Attempt Validation rating Avg validation error LOO-CV median
1 Good 147 px (6% screen) 135 px
2 Fair 164 px (8% screen) 148 px

Without pooling, a subject who redid calibration because attempt 1's first validation run came back "Fair" would have their better attempt's sixteen points discarded entirely in favour of a second attempt that — as this real pair of outcomes shows — is not guaranteed to be better. With pooling (head pose permitting), both attempts' sixteen-point data contribute to one combined model, so a redo can only add information, never strictly discard a perfectly good first attempt's worth of data merely because the subject chose to redo.

At the individual calibration-point level, suppose one point measured a 305 px-equivalent collection error in attempt 1 (sdX = sdY = 0.05) and a 49 px-equivalent error in attempt 2 (sdX = sdY = 0.005 — ten times cleaner). Inverse-dispersion weights are 1/(0.05² + 0.05²) = 200 and 1/(0.005² + 0.005²) = 20000 respectively — a ~100:1 ratio — so the combined iris-offset coordinate sits at roughly 1% of the way from attempt 2's coordinate toward attempt 1's, not at the 50% midpoint a plain average would produce. A unit test (calibrationEngine.test.ts, "a low-dispersion attempt dominates pooling over a high-dispersion attempt at the same point") fixes this behaviour numerically: under plain averaging the resulting model mispredicts a probe at the clean attempt's coordinate by 163 px; under inverse-dispersion weighting, by under 60 px.

6.5 Extension to the 8-point validation phase

The same inverse-dispersion pooling applies one layer up, to the post-validation affine correction (companion paper, §6) rather than the TPS surface itself. Each of the eight validation dots already records a median gaze position and, since this scheme, the sample dispersion (sdX, sdY) at the moment that dot's collection completed — the same statistic §6.2 uses for the sixteen training points. On a redo, a validation attempt's eight per-dot results are retained (priorAttemptsValGazeRef) rather than discarded, and the affine fit is trained on, for each of the eight dot positions, the inverse-dispersion-weighted combination of every attempt's result at that position — a clean second look at a dot dominates a noisy first one exactly as in §6.2, rather than averaging the two into a worse compromise.

This pooling is gated by the same head-pose safety check as the training-point pooling: if the calibration the validation immediately follows discarded its own pooled prior attempt for head-pose drift (calibrationEngine.wasLastAttemptPooled() returns false), the validation phase's prior-attempt history is cleared too (clearPriorAttempts()), since a validation result collected at a stale head position is exactly as unsafe to blend as a training point would be. A validation attempt that ends in an outright failed model build, or is abandoned via the calibration-failure dialog, also clears this history unconditionally — there is no model whose validation history is worth preserving in either case.

6.6 The limit of dispersion-weighting alone: bias versus variance

Inverse-dispersion weighting (§6.2) protects against a noisy attempt diluting a clean one — it weights by each attempt's own internal consistency (sample dispersion). It does not protect against a confidently wrong attempt: a tracking glitch (e.g. a brief lock onto an eyebrow or glasses rim instead of the iris) that happens to produce a low-dispersion reading gets a HIGH weight under pure dispersion-weighting precisely because it looks clean, even though the coordinate itself is wrong. Dispersion measures precision, not correctness, and the two are independent.

This is addressed asymmetrically for the two phases, because only one of them has access to ground truth at pooling time:

  • Training points (calibration) have no ground truth at collection time — the dot's screen position is known, but the recorded iris-offset coordinate has no independently-known "correct" value to check against until a model exists, which is exactly what's being built. The available signal is therefore cross-attempt agreement: if two attempts' raw collections of the same point disagree by more than MAX_PAIRWISE_IRIS_DISAGREEMENT (derived, not guessed — see below), pooling stops trying to blend them and falls back to trusting only the lower-dispersion attempt outright, discarding the rest for that point. This is a heuristic, not a proof: if the wrong attempt happens to also have the lower dispersion of the pair, this check picks it. It is, however, a meaningful improvement over unconditional blending in the common case, where a tracking glitch (blink, occlusion, brief mistracking) also elevates dispersion, not just bias.
  • Validation points have ground truth — each of the eight dots has a known target screen position, so any attempt's pixel error against that target is directly computable without needing a model first. A VALIDATION_OUTLIER_PX ceiling rejects any individual attempt whose error exceeds it before pooling, regardless of how low that attempt's own dispersion looks. This closes the bias/variance gap completely for validation, since correctness — not just precision — is directly checkable.

Both thresholds are derived from constants already established in this codebase rather than newly chosen:

  • MAX_PAIRWISE_IRIS_DISAGREEMENT (≈0.15 iris-offset units) = GAZE_PROXIMITY_THRESHOLD (0.12, the existing collection-time proximity gate, in screen-normalised units) divided by 0.80 — the same amplification factor getFallbackGazePoint() uses to convert iris-offset space to screen-normalised space, run in reverse to convert the proximity gate's own tolerance back into iris-offset units.
  • VALIDATION_OUTLIER_PX (450px) = 3× bootstrapWarningThresholdPx (150px) — the existing ceiling beyond which computeConfidenceScore already treats validation error as maximally bad. 3× that margin keeps the cutoff well clear of the range of genuinely poor-but-real sessions (which themselves run up to ~150–200px per that same scoring formula's own saturation points), so it only rejects values far outside even a bad-but-real reading.

A unit test (calibrationEngine.test.ts, "attempts that disagree beyond MAX_PAIRWISE_IRIS_DISAGREEMENT fall back to winner-take-all, not a blend") and two companion tests in useCalibrationValidation.test.ts ("absolute outlier rejection") verify both mechanisms numerically, each confirmed to fail under the prior (dispersion-weighting-only) behaviour before the fix and pass after it.

7. Discussion

The regularisation scheme in §4 illustrates a general principle for any per-point statistical procedure aggregated from variable-quality observations: a quality-weighting formula that mixes two independent quality signals multiplicatively, with each signal's contribution individually capped, behaves predictably only if neither signal can fully override the other; a partial cap (the × 0.5 term in the earlier formulation) reintroduces exactly the failure mode the weighting was meant to prevent, in a way that is not visible from training error alone, because a near-exactly-interpolating model has near-zero training error regardless of which points it was forced to fit exactly. This is the motivation for evaluating calibration quality by Leave-One-Out Cross-Validation rather than training error, the subject of the companion paper in this series.

8. Conclusion

A sixteen-point Thin-Plate Spline calibration, with regularisation weighted per point by sample count and within-point dispersion rather than applied uniformly, allows the platform to extract a usable gaze-calibration model from a child's necessarily imperfect attention across sixteen fixation targets, while bounding the damage any single poorly-collected point can do to the rest of the screen. Redo attempts pool with prior data rather than discarding it outright, subject to the same head-pose consistency the platform already enforces elsewhere, so a subject's first attempt is never wasted by the act of trying again.

References

  1. Bookstein, F. L. (1989). Principal warps: thin-plate splines and the decomposition of deformations. IEEE Transactions on Pattern Analysis and Machine Intelligence, 11(6), 567–585.
  2. Duchowski, A. T. (2017). Eye Tracking Methodology: Theory and Practice (3rd ed.). Springer.
  3. Wahba, G. (1990). Spline Models for Observational Data. SIAM. [Regularised spline fitting]
  4. Sugano, Y., Matsushita, Y., & Sato, Y. (2014). Learning-by-synthesis for appearance-based 3D gaze estimation. CVPR 2014. [Appearance-based webcam gaze estimation context]

Appendix A — Calibration Grid Layout

The platform uses a 4×4 grid of sixteen calibration points spanning normalised screen coordinates, with corner and edge points at higher eccentricity from centre deliberately included so that the fitted spline is constrained at the screen periphery rather than only at the centre, where unconstrained extrapolation produces the largest errors.

Appendix B — Regularisation Reference Table

Quality profile accepted sdX+sdY q λ
Excellent 30 0.005 ≈0.96 ≈0.057
Typical 15 0.010 ≈0.42 ≈0.137
Forced (timed out) 0 — — 0.200 (direct)
Noisy, high sample count 30 0.052 ≈0.57 ≈0.115

Appendix C — Pseudocode

function computePointLambda(accepted, sdX, sdY, forced):
    if forced: return 0.2
    sampleQuality = min(accepted / 30, 1)
    sdPenalty     = min((sdX + sdY) / 0.12, 1)
    q             = sampleQuality * (1 - sdPenalty)
    return 0.05 + (1 - q) * 0.15

Important: DysTest is a screening tool and does not provide a formal medical diagnosis.