Port step 4: measure the anchor and the mouth, condition on its own
`stabilize` is three things wearing one name, and it is now three functions in two stages: `flow/measure/anchor` fits the rigid transform, `flow/condition` smooths its parameters, `flow/measure/mouth` measures the lip rings through the result. Parity is on the COMPOSITION and not on the pieces -- a split that agreed function by function and not end to end would be a split rather than a port. The oracle now drives `stabilize` at three configurations and the port agrees to 1e-9 on ref, rigid, transforms, outer, inner and aperture, plus `smoothContours` at three radii. Two of the three configurations are at aspect 0.5625, a 1080x1920 phone clip, because at aspect 1 `pick` is the identity: a port that dropped the anisotropy correction outright would pass every other assertion in the suite. 148 tests, up from 134. Three decisions worth the reading time. `makeXform` is not ported, and its absence takes the face oval with it. It centres on the oval's bounding box and zooms until the face is 80% of the raster height, so every vertex it touched carried a cropping decision made once, at analysis time, from one frame's landmarks. Geometry belongs in the node's own local space with the framing as a transform on a node, so this is a deletion. The oval's only other consumer was the placeholder plate outline, which is painting. The residual is taken against the RAW fit, and the prototype took it against the smoothed one. That is the only deliberate numeric divergence here, and parity is kept by asserting `anchor/residuals` on exactly what the prototype handed it. The number's job is to say whether a section is stabilisable at all; folding the smoothing error into it makes a slider look like a property of the footage, and docs/architecture.md lists the residual under stage 3, which requires it to be knob-free. `condition/anchor` therefore replaces `:transforms` and leaves `:residual` alone. The stage order is not the strict chain the table in docs/architecture.md looks like, and that document now says so. The fit is knob-free, conditioning smooths it, and the rings are measured *through* the conditioned transform -- so `anchor avg` does re-run the ring mapping, which is a few hundred frames of twenty points. The guarantee was only ever about the part that reads a source pixel, and that part never sees a transform. Two things fall out and are asserted rather than assumed. Smoothing and subsampling commute, because both are per-slot, which is what lets `vertices` stay a stage-5 knob downstream of a stage-4 one -- and it is also why the port can smooth the full twenty slots where the prototype smooths eight and still match. And `condition/contours` is `geom/moving-average` per vertex per axis rather than its own clamped window, so "radius 2" cannot come to mean two different things at the two knobs. One dead end recorded so nobody walks it twice: the synth's head is perfectly rigid -- its jitter is a whole-head translation, which a similarity absorbs exactly -- so every frame's rigid configuration is congruent with frame zero's and the Procrustes mean IS frame zero to 1e-15, jitter or none. "The reference is the mean and not frame zero" cannot be asserted on this track and is asserted in geom-test, where the two can differ. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
11192d61c6
commit
942e2f38ab
10 changed files with 494 additions and 1 deletions
|
|
@ -21,6 +21,7 @@ import { RIGID, LIPS_OUTER, EYE_R_RING, BROW_A_RING, FACE_OVAL,
|
|||
subsampleSlots } from '../../../js/landmarks.js';
|
||||
import { fitSimilarity, applySim, fitResidual, procrustesMean,
|
||||
movingAverage, smoothTransforms, offsetRing } from '../../../js/mathutil.js';
|
||||
import { stabilize, smoothContours } from '../../../js/pipeline.js';
|
||||
import { synthDense } from '../../../js/synth.js';
|
||||
import { IndexedRaster, hexToRgb } from '../../../js/raster.js';
|
||||
|
||||
|
|
@ -34,6 +35,8 @@ const ref = procrustesMean(rigid);
|
|||
const tfs = rigid.map((r) => fitSimilarity(r, ref));
|
||||
|
||||
const strip = (p) => ({ x: p.x, y: p.y, z: p.z ?? 0 });
|
||||
const xy = (p) => ({ x: p.x, y: p.y });
|
||||
const ring = (r) => r.map(xy);
|
||||
const stripTf = (t) => ({ s: t.s, theta: t.theta, tx: t.tx, ty: t.ty });
|
||||
|
||||
// A known transform recovered exactly, which is the same case the CLJS unit test
|
||||
|
|
@ -59,6 +62,42 @@ const out = {
|
|||
movingAverage: [0, 1, 2, 3, 7].map((radius) => ({
|
||||
radius, vals: movingAverage(tfs.map((t) => t.tx), radius),
|
||||
})),
|
||||
// stabilize(), which the CLJS side reaches as three stages: the anchor fit,
|
||||
// the conditioning of its parameters, and the mouth measured through the
|
||||
// result. Diffing the composition is the point — a split that agreed on each
|
||||
// piece and not on the whole would be a split, not a port.
|
||||
//
|
||||
// aspect 1 is in here to isolate the rest, and 0.5625 (a 1080x1920 phone clip)
|
||||
// because it is the only value that exercises the anisotropy correction at all:
|
||||
// at aspect 1 `pick` is the identity and a port that dropped it entirely would
|
||||
// pass. radius 0 and 2 because the split moved the smoothing OUT of the middle
|
||||
// of this function, so agreeing only at radius 0 would prove nothing about it.
|
||||
stabilize: [{ aspect: 1, radius: 0 },
|
||||
{ aspect: 0.5625, radius: 0 },
|
||||
{ aspect: 0.5625, radius: 2 }].map(({ aspect, radius }) => {
|
||||
const st = stabilize(track, radius, aspect);
|
||||
return {
|
||||
aspect, radius,
|
||||
ref: st.ref.map(xy),
|
||||
rigid: st.rigid.map(ring),
|
||||
transforms: st.transforms.map(stripTf),
|
||||
residual: st.residual,
|
||||
outer: st.outer.map(ring),
|
||||
inner: st.inner.map(ring),
|
||||
aperture: st.aperture,
|
||||
};
|
||||
}),
|
||||
// The contour knob, on the ring it is actually dragged for. The rings are the
|
||||
// full 20 slots and not a subsample, which is where the CLJS side differs in
|
||||
// arrangement and must not differ in numbers: the prototype subsamples before
|
||||
// smoothing, the port smooths before subsampling, and the two commute because
|
||||
// both operations are per-slot.
|
||||
smoothContours: (() => {
|
||||
const st = stabilize(track, 0, 0.5625);
|
||||
return [0, 1, 3].map((radius) => ({
|
||||
radius, outer: smoothContours(st.outer, radius).map(ring),
|
||||
}));
|
||||
})(),
|
||||
offsetRing: [0, 0.5, 2, -1].map((d) => ({
|
||||
d,
|
||||
ring: offsetRing(LIPS_OUTER.map((i) => track[0][i]), d).map(strip),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue