From 281cebea7e337c58cfebe3ee78fada2666e67ec9 Mon Sep 17 00:00:00 2001 From: shinyobjectz Date: Sat, 5 Dec 2026 12:54:14 -0800 Subject: [PATCH] raea check: four kinds of run 28's ERRORs that weren't faults Each judged on the frame or the sound (12-05, proof run 28: Dutch, Elfster and Body Shop through Brief-to-Video). - frames: a face cut by the edge is an error only when the reader is at least 80% sure, over its run, that it's a face. Elfster's "face cut by the left edge" was a hand at 0.79 then 0.65; the people in the shot read 0.92 and over. Below that it's a warning that says how sure the reader is. - captions: a word said on an end card the render drew counts as captioned. captionsOf takes a frame full of text for a card, not captions, so the CTA read out over its own end card was "4.2 s of talking with no caption". Only the manifest's own texts count, never the footage's. - place: a caption is over "words in the shot" only when it hides 30% of them or more. Over a sign's top edge, its words all read, it's a warning ("the edge of a sign"): Dutch's "Would" and "this.". - contrast: the ratio to two places, rounded down, so 2.96 no longer reads "3.0:1 ... make it at least 3:1". --- apps/check/src/picture.rs | 2 +- sdk/goal/src/packs/captions.ts | 15 ++++++++++--- sdk/goal/src/packs/frames.ts | 39 ++++++++++++++++++++++------------ sdk/goal/src/packs/place.ts | 8 ++++++- sdk/goal/test/captions.test.ts | 3 +++ sdk/goal/test/frames.test.ts | 4 ++++ sdk/goal/test/place.test.ts | 7 ++++++ 7 files changed, 59 insertions(+), 19 deletions(-) diff --git a/apps/check/src/picture.rs b/apps/check/src/picture.rs index 8033d495..2c45973e 100644 --- a/apps/check/src/picture.rs +++ b/apps/check/src/picture.rs @@ -219,7 +219,7 @@ pub(crate) fn contrast(video: &str, runs: &[Run], w: f64, h: f64, probe: &Probe, measured += 1; if ratio < 3.0 { low += 1; - issues.push(Issue { rule: "contrast", p: 1, at: Some(t), says: format!("{} is {ratio:.1}:1 against what's behind it; make it at least 3:1 (a band, a shadow for separation, or another colour)", quote(&r.text)) }); + issues.push(Issue { rule: "contrast", p: 1, at: Some(t), says: format!("{} is {:.2}:1 against what's behind it; make it at least 3:1 (a band, a shadow for separation, or another colour)", quote(&r.text), (ratio * 100.0).floor() / 100.0) }); } } if measured > 0 && low == 0 { diff --git a/sdk/goal/src/packs/captions.ts b/sdk/goal/src/packs/captions.ts index 725715fd..32df4543 100644 --- a/sdk/goal/src/packs/captions.ts +++ b/sdk/goal/src/packs/captions.ts @@ -226,7 +226,7 @@ const HOOK_S = 5 * had none, read from its brief's "captions OR a text hook"): a cut with talking and no captions at all is an error, * and so is a stretch of talking with none up. A text hook may be on screen beside them; it doesn't stand in for them. * A brief that wants no captions says so, and the render says it with --despite captions WHY */ -export function uncaptioned(shown: Shown[], heard: Word[], textUp: (t: number) => boolean = () => false): Finding[] { +export function uncaptioned(shown: Shown[], heard: Word[], textUp: (t: number) => boolean = () => false, onCard: (w: Word) => boolean = () => false): Finding[] { heard = asDigits(heard) // a brief's "captions OR a text hook, never both" means not both in one frame (12-03, Shane): the hook may hold the // opening alone, so words in the first HOOK_S with other text up are covered by it; anywhere later it's no caption @@ -237,7 +237,9 @@ export function uncaptioned(shown: Shown[], heard: Word[], textUp: (t: number) = if (said.length < BARE.error.words) return [] const fix = "caption every line from the words file (whole phrases in the brand's caption style); a text hook goes with the captions, never instead of them. If the brief asks for no captions, render with --despite captions WHY" if (!shown.length) return [{ level: "error", kind: "uncaptioned", at: said[0].start, says: `no captions over the talking: ${said.length} words, ${(said[said.length - 1].end - said[0].start).toFixed(1)} s, and no caption track (captions one after another under ${Math.round(TRACK * 100)}% of what's said, or fewer than ${CARDS} of them). ${fix}` }] - const up = (w: Word) => shown.some((s) => w.end >= s.from - 0.6 && w.start <= s.to + 0.3) + // a word is up when a caption is, or when text the render drew says it there (an end card with the line being said: + // captionsOf takes a frame full of text for a card, not captions; 12-05, run 28's Elfster end cards) + const up = (w: Word) => shown.some((s) => w.end >= s.from - 0.6 && w.start <= s.to + 0.3) || onCard(w) const out: Finding[] = [] for (let i = 0; i < said.length; ) { if (up(said[i])) { i++; continue } @@ -310,6 +312,13 @@ export default check( const rate = own ? own.rate : sc!.rate || 2 const shown = captionsOf(frames, rate, heard) const textUp = (t: number) => (frames[Math.round(t * rate)]?.lines ?? []).some(([, , , , text, score]) => score >= LEAST && letters(text).length >= 4) - for (const x of [...uncaptioned(shown, heard, textUp), ...compare(shown, heard, own ? await placedWords(f) : [])].sort((a, b) => a.at - b.at)) found({ level: x.level, says: x.says, seconds: x.at }) + // only the render's own texts say a word on screen: the footage's own (a sign, a phone) never caption anything + const onCard = (w: Word) => { + if (!own) return false + const k = letters(w.text) + const at = (t: number) => letters((frames[Math.round(t * rate)]?.lines ?? []).map((l) => l[4]).join(" ")) + return k.length > 0 && [w.start, (w.start + w.end) / 2, w.end].some((t) => at(t).includes(k)) + } + for (const x of [...uncaptioned(shown, heard, textUp, onCard), ...compare(shown, heard, own ? await placedWords(f) : [])].sort((a, b) => a.at - b.at)) found({ level: x.level, says: x.says, seconds: x.at }) }, ) diff --git a/sdk/goal/src/packs/frames.ts b/sdk/goal/src/packs/frames.ts index 49f819b6..feffb28f 100644 --- a/sdk/goal/src/packs/frames.ts +++ b/sdk/goal/src/packs/frames.ts @@ -6,7 +6,9 @@ // (no one reads it on a phone), under 48 px a warning. // faces: frames two a second through the scene reader (raea cloud's farm). A face of a person in the shot (5% of the // frame's height or more) touching an edge or a split screen's seam: a second or more is an error, shorter a -// warning. A split screen with a face in one half only is a warning. +// warning. The reader takes a hand or a bag at the edge for a face now and then (12-05, run 28: Elfster's "face cut by +// the left edge" was a hand at 0.79 then 0.65, where the people in the shot read 0.92 and over), so a run it's less +// than FACE_SURE sure of is a warning, never an error. A split screen with a face in one half only is a warning. // A face at the edge that's meant (someone walking out of shot) is said, with its reason, in OUT.despite.txt beside // the video: its findings are then warnings. import { existsSync, readFileSync } from "node:fs" @@ -17,6 +19,9 @@ import { quote } from "../text.ts" /** a face this share of the frame's height or more is someone in the shot, not a passer-by far behind */ export const FACE_MIN = 0.05 +/** a cut face is an error only when the reader is this sure, over its run, that it's a face (a face's score; 1 when the + * reader gives none) */ +export const FACE_SURE = 0.8 /** least font sizes, in pixels of a frame 1080 wide (its shorter side): the Direct Response skill's table */ export const TEXT_ERROR = 40 export const TEXT_WARN = 48 @@ -43,17 +48,21 @@ export function splitsOf(fr: NonNullable): Split[] { const near = (a: Split, b: Split) => a.axis === b.axis && Math.abs(a.at - b.at) <= 6 const big = (fr: NonNullable) => fr.faces.filter((f) => f[3] >= fr.h * FACE_MIN) -/** what cuts a face in a frame: an edge of the frame, or a split screen's seam */ -function cutBy(fr: NonNullable, splits: Split[]): string | null { - for (const [x, y, fw, fh] of big(fr)) { - if (x <= 1) return "the left edge" - if (x + fw >= fr.w - 1) return "the right edge" - if (y <= 1) return "the top edge" - if (y + fh >= fr.h - 1) return "the bottom edge" - for (const sp of splits) { - const [a, b] = sp.axis === "h" ? [y, y + fh] : [x, x + fw] - if ((a < sp.at - 2 && b > sp.at + 2) || Math.abs(b - sp.at) <= 3 || Math.abs(a - sp.at) <= 3) return "the split screen's seam" - } +/** what cuts a face in a frame (an edge of the frame, or a split screen's seam), with how sure the reader is it's a face */ +function cutBy(fr: NonNullable, splits: Split[]): { by: string; score: number } | null { + for (const [x, y, fw, fh, s] of big(fr)) { + const score = Number.isFinite(s) ? s : 1 + const by = + x <= 1 ? "the left edge" + : x + fw >= fr.w - 1 ? "the right edge" + : y <= 1 ? "the top edge" + : y + fh >= fr.h - 1 ? "the bottom edge" + : splits.some((sp) => { + const [a, b] = sp.axis === "h" ? [y, y + fh] : [x, x + fw] + return (a < sp.at - 2 && b > sp.at + 2) || Math.abs(b - sp.at) <= 3 || Math.abs(a - sp.at) <= 3 + }) ? "the split screen's seam" + : null + if (by) return { by, score } } return null } @@ -83,10 +92,12 @@ export function cutFaces(frames: Faces[], rate = RATE): Finding[] { const held = raw.map((ss, i) => ss.filter((s) => (raw[i - 1] ?? []).some((o) => near(s, o)) || (raw[i + 1] ?? []).some((o) => near(s, o)))) const out: Finding[] = [] const hits = frames.map((fr, i) => (fr ? cutBy(fr, held[i]) : null)) - for (const [i, j, by] of runs(hits)) { + for (const [i, j, { by }] of runs(hits, (a, b) => a.by === b.by)) { const from = i / rate const to = j / rate - out.push({ level: to - from >= 1 ? "error" : "warn", kind: "face-cut", at: from, until: to, says: `a face is cut by ${by} from ${from.toFixed(1)} s to ${to.toFixed(1)} s: reframe on the person (both eyes, mouth and chin inside the picture)${by.includes("seam") ? ", or cut between two singles" : " or cut away"}` }) + const sure = hits.slice(i, j).reduce((n, h) => n + (h?.score ?? 0), 0) / (j - i) + const doubt = sure < FACE_SURE ? ` (the reader is ${Math.round(sure * 100)}% sure it's a face: look)` : "" + out.push({ level: to - from >= 1 && !doubt ? "error" : "warn", kind: "face-cut", at: from, until: to, says: `a face${doubt} is cut by ${by} from ${from.toFixed(1)} s to ${to.toFixed(1)} s: reframe on the person (both eyes, mouth and chin inside the picture)${by.includes("seam") ? ", or cut between two singles" : " or cut away"}` }) } const split = held.map((ss) => ss[0] ?? null) for (const [i, j, sp] of runs(split, near)) { diff --git a/sdk/goal/src/packs/place.ts b/sdk/goal/src/packs/place.ts index 99f584ae..25c95576 100644 --- a/sdk/goal/src/packs/place.ts +++ b/sdk/goal/src/packs/place.ts @@ -36,6 +36,8 @@ const SUBJECT_MIN = 0.25 const FACE_IN_SHOT = 0.05 /** a thing this share of the frame's area or more is what the shot shows (a dog at someone's feet, a phone held up) */ const THING_MIN = 0.006 +/** words in the shot are hidden (text over them an error) when a text covers this share of them or more */ +export const SIGN_HIDDEN = 0.3 /** a text is badly placed when it costs this much or more, and a clear place costs this much less */ export const BAD = 1.6 export const BETTER = 1.2 @@ -123,7 +125,11 @@ function thingsUnder(s: NonNullable, b: Box, ours: Box[] = []): string[] const [x, y, w, h] = [t[0] / s.w, t[1] / s.h, t[2] / s.w, t[3] / s.h] const ix = Math.max(0, Math.min(b[0] + b[2], x + w) - Math.max(b[0], x)) const iy = Math.max(0, Math.min(b[1] + b[3], y + h) - Math.max(b[1], y)) - if (ix * iy > 0.12 * Math.min(w * h, b[2] * b[3])) out.add(t[4] === "person" ? "a person in the shot" : t[4] === "face" ? "a face" : t[4] === "text" ? "words in the shot (a sign)" : `a ${t[4].replace(/_/g, " ")}`) + if (!(ix * iy > 0.12 * Math.min(w * h, b[2] * b[3]))) continue + // words in the shot are covered when a good part of them is hidden; a caption over a sign's top edge leaves them read + // (12-05, run 28: Dutch's "Would" and "this." sat on the edge of a handwritten sign, its words all clear) + if (t[4] === "text") out.add(ix * iy >= SIGN_HIDDEN * w * h ? "words in the shot (a sign)" : "the edge of a sign") + else out.add(t[4] === "person" ? "a person in the shot" : t[4] === "face" ? "a face" : `a ${t[4].replace(/_/g, " ")}`) } return [...out] } diff --git a/sdk/goal/test/captions.test.ts b/sdk/goal/test/captions.test.ts index bbba1dde..37db3ab8 100644 --- a/sdk/goal/test/captions.test.ts +++ b/sdk/goal/test/captions.test.ts @@ -90,6 +90,9 @@ test("captions are a must: a cut that talks with only a text hook up fails, a ba expect(uncaptioned(captionsOf(hookThenCaps, 2, said), said, hookUp)).toEqual([]) // text up all through doesn't stand in for captions after the opening expect(uncaptioned(track, said, () => true).map((x) => x.level)).toEqual(["error"]) + // the bare stretch said on an end card the render drew (12-05, run 28's Elfster): the card says it, nothing more + const card = new Set(said.filter((w) => w.start >= 7).map((w) => w.text)) + expect(uncaptioned(track, said, () => false, (w) => card.has(w.text))).toEqual([]) // a cut with hardly any talking needs none expect(uncaptioned([], said.slice(0, 4))).toEqual([]) }) diff --git a/sdk/goal/test/frames.test.ts b/sdk/goal/test/frames.test.ts index c0713009..e669e6a0 100644 --- a/sdk/goal/test/frames.test.ts +++ b/sdk/goal/test/frames.test.ts @@ -11,6 +11,10 @@ test("the frames pack's measures", () => { let f = cutFaces([fr([whole]), fr([edge]), fr([edge]), fr([whole]), fr([edge]), fr([[0, 50, 10, 12, 0.9]])]) assert.deepEqual(f.map((x) => [x.level, x.at, x.until]), [["error", 0.5, 1.5], ["warn", 2, 2.5]]) assert.match(f[0].says, /left edge/) + // a hand at the edge the reader half takes for a face (12-05, run 28: 0.79 then 0.65): a warning that says so + f = cutFaces([fr([[0, 598, 41, 82, 0.79]]), fr([[0, 594, 40, 84, 0.65]]), fr([whole])]) + assert.deepEqual(f.map((x) => [x.level, x.at, x.until]), [["warn", 0, 1]]) + assert.match(f[0].says, /72% sure it's a face/) // a split screen: a lone line held; a caption's box (two lines close together) isn't one assert.deepEqual(splitsOf(fr([], [["h", 480, 0.8]])), [{ axis: "h", at: 480 }]) assert.deepEqual(splitsOf(fr([], [["h", 446, 0.8], ["h", 513, 0.8]])), []) diff --git a/sdk/goal/test/place.test.ts b/sdk/goal/test/place.test.ts index 74555027..ec609be3 100644 --- a/sdk/goal/test/place.test.ts +++ b/sdk/goal/test/place.test.ts @@ -41,6 +41,13 @@ test("the place pack's model", async () => { assert.ok(pa.places[0].top < 400, JSON.stringify(pa.places[0])) ok("raea make place keeps a caption off the sign in the shot") + // a caption over a sign's top edge, its words all read, is a warning (12-05, run 28's Dutch: "Would" and "this." on + // the edge of a handwritten sign): 30% of the words' box hidden makes it "words in the shot", an error + const signed = { w: 540, h: 960, grid: { cols: 27, rows: 48, people: Array(48).fill("0".repeat(27)) }, faces: [], things: [[60, 520, 420, 70, "text", 0.95], [60, 600, 420, 70, "text", 0.95]] } + const onEdge = textOver(man([t("Would", 400, 950, 280, 110)]), [signed], 1) + assert.ok(onEdge.every((x) => x.level === "warn" && /the edge of a sign/.test(x.says)), JSON.stringify(onEdge)) + ok("a caption over a sign's edge is a warning") + // b: a woman filling the frame; a caption over her coat is at most a warning const b = textOver(man([t("Did you know you", 272, 1344, 536, 88)]), [sc.b], 1) assert.ok(b.every((x) => x.level === "warn"), JSON.stringify(b))