Expand description
Photometric motion evidence on analysis and native images: hypothesis generation from matches, patch errors, audits and integer refinement. Every threshold is the historical one; tie-breaking (first minimum, distance to the guess) is preserved so reconstructions stay reproducible.
Structs§
- Audit
- Extracted
Patch - One
extractPatchesoutput patch: region-local native pixels plus itssize × sizeluma data. - Gray
- Match
Points - Matched point pairs
(a.x, a.y, b.x, b.y, unique)in analysis pixels. - Motion
- Motion
Field - Native
Refinement - Patch
- Keyframe patch (region-local origin,
size×sizenative luma). - Patch
Error - Point
Constants§
- MOTION_
CELL - Fixed motion-field cell size (analysis pixels per side). Shared with
abi::ls_layoutselector 9 so the TS binding’s layout assertion actually guards it instead of duplicating a bare literal. - TRIMMED_
KEEP - Share of the per-point errors
NativeRefinement::trimmedkeeps. On real steps the plain mean rejected (a sidebar at 14.3, a tab bar at 14.9) 70, 75 and 80 % trims gave 2.5–5.7 at the true offset and at least 15.7 at offsets 3 or 10 px off or at zero; 75 % is the middle one.
Functions§
- audit_
translation - Held-out photometric evidence on textured pixels with both observations clamped to the pane.
- detect_
scale - RANSAC similarity probe over unique matches; a change detector, never a licence to rescale pixels.
- estimate_
motion - Per-cell motion labelling of
bagainstafrom pre-computed matches (currentb→ previousa). - extract_
patches - Native-resolution texture samples around
features(analysis-resolution points, scaled byfactor), non-overlapping, clamped toregion, firstcountaccepted in feature order.nativeis the FULL native luma plane (native_width × native_height); a caller-suppliedregionthat would read outside it is rejected (empty result) instead of indexing past the plane — the historical TS never validated this because a JS typed-array read past the end just returnsundefined, but a Rust slice index would panic. - patch_
error - Clipped robust error of
bagainstashifted by (dx, dy), sampled everysteppixels insider. - probe_
scale - When translation fails, asks explicitly whether
previous(resampled at each candidate scale) explainscurrent— fusesresampleGray+extractFeatures(320)+matchFeatures+translationHypotheses(4)+ the support/audit gates into one call per candidate scale, exactly the historical TS loop’s order. First strict minimum byagreeingErrorin scale order (matches the TS!best || audit.agreeingError < best.error). - refine_
native - Native-pixel refinement on textured luma edges of
binsideregion, matching againstaat integer offsets.labels/code(region atlas membership) restrict both frames when given. Composesselect_native_pointsandrefine_native_at; a caller evaluating several candidates over the sameb/region/maskshould call those directly to select once and reuse the points (seetrack::odometry). - refine_
native_ at - Native-pixel refinement of
bagainstaat integer offsets, given points already chosen byselect_native_pointsfor thisb/region/mask. Split out ofrefine_nativeso a caller with several hypotheses over the same region (track::odometry) selects the points once and reuses them. - refine_
patches - Aligns keyframe patches in the current native luma frame at integer offsets around
guess(current → keyframe). - refine_
spatial_ patches - Re-acquisition must represent the whole pane: many patches on one fixed control are not many independent votes for its motion. Weight each patch by its nearest-neighbour cell’s area, sampled at the patch scale. Drift refinement keeps its original texture-weighted residual.
- refine_
translation - Integer refinement of
pwithinradiusby patch error; ties resolve toward the original guess. - resample_
gray - Bilinear resample of an analysis image (probe only; output pixels are never resampled).
- sampling_
insensitive_ error refine_native_at’s cost of the points atoffset, and its runner-up (the lowest cost at an offset more than two pixels from it, withinradius), with each point compared by Birchfield and Tomasi’s sampling-insensitive dissimilarity (“A Pixel Dissimilarity Measure That Is Insensitive to Image Sampling”, 1998) instead of the plain difference. Each value is compared with the range the other image spans within half a pixel of the matching position (the halfway points to its four neighbours), and the smaller of the two directions counts, so content that moved by a fraction of a pixel costs what it would at whole-pixel motion. Displacements of a pixel or more still cost in full. Infinite where fewer than 12 points fall inside both frames, as in the plain cost.- screen_
fixed_ split_ error - The cost of the points at
offsetand its runner-up (the lowest cost more than two pixels away, withinradius), when the region may hold a screen-fixed part: each point costs the smaller of its plain error at zero (refine_native_at’s per-point cost) and its sampling-insensitive error at the offset (sampling_insensitive_error’s per-point cost). A point that stayed where it was on screen (a search bar or status bar floating over a map, a sticky panel) then does not count against the offset the rest moved by, and the rest may have moved by a fraction of a pixel, as a decelerating fling does. A frame that did not move matches at zero everywhere, so every offset then costs about the same as the runner-up. Infinite where fewer than 12 points fall inside both frames, as in the plain cost. The third value is the share of the points the offset explains better than zero, among those one of the two explains better: the part that moved, against the part that stayed. - select_
native_ points - Picks the native-refinement sample points for
binsideregion: astep×stepcell grid, keeping one point per cell rather than sampling only the pixel at the cell’s corner (its lattice node). A node-only sampler finds an edge with probability proportional to local edge density, so a sparse page (few edges anywhere) starves the sample (< 12points →Infinity, the true step read as “static”) and a screen-fixed line that happens to align with a lattice row or column dominates it (every node on that row is an edge, nothing else is) — see docs/ARCHITECTURE.md §五/§十. Depends only onb,region,maskandguide, not on any hypothesis, so a caller evaluating several candidate displacements can select once and reuse the points for all of them. - translation_
hypotheses - Candidate translations (current → previous) from binned match displacements, strongest first.
- verify_
translation - Retained-75% mean of 48px block errors: ordinary page content must agree, not a single logo.