Files
raea/sdk/cloud/test/place.ts
shaneandshinyobjectz 6af8bfa5bb Cut checks a box can fail on: raea sound check, text placement from the farm's scene read, and full render manifests (#267)
Shane on Dutch (11-29): words faded and cut in two, lines too quiet to hear, effects no one hears, and text laid
over the people and the dog the shot is about.

- raea sound check VIDEO (server/sound.ts): each voice clip's edit points against the take's words and its sound.
  A cut inside a word or on a word's sound is an error, and the message names the pause (or the boundary) to move
  it to. Lines more than 6 dB from the cut's median are an error, with the gainDb that evens them. An effect 10 dB
  or more under the voice is an error, since no one hears it. Buried or fighting music is a warning. offload.ts runs
  it after every render that has a manifest.
- The farm's POST /v1/scene (deploy/modal/farm_scene.py) reads a frame: people as a mask, faces, COCO's things,
  and words in the shot (four small OpenCV zoo models on the CPU, each pinned by its hash).
- server/place.ts turns a scene into costs. raea frames check now fails text over a face, a dog or a person when a
  clear place of its size exists, and names that place. raea frames place FILE lists the clear places in a take.
  Stacked lines move as one block, our own text isn't counted as the shot's words, and passers-by's small faces
  don't count.
- The farm wrote a split render's probe manifest (frame 0 only) as the render's. Each run now writes its own and
  the farm joins them, so the checks see every frame and every clip.

Tests: test/sound.ts (7), test/place.ts (4, on scene reads of three interview frames, boxes only),
test/farm_plan.py (the joined manifest).

Co-authored-by: shinyobjectz <[email protected]>
2026-11-29 09:20:52 -08:00

41 lines
2.7 KiB
TypeScript

// Text placement (server/place.ts) on three frames of street interviews, read by the farm's scene models
// (deploy/modal/farm_scene.py; the fixture holds only their boxes and grids): node test/place.ts
// 11-29 (Dutch): a caption laid over the dog the shot is about, a checklist on a woman's lap, beside a sign that is the
// ad's own hook
import assert from "node:assert/strict"
import { readFileSync } from "node:fs"
import { placeReport, textOver } from "../server/place.ts"
const ok = (m: string) => console.log(`ok ${m}`)
const sc = JSON.parse(readFileSync(new URL("./fixtures/scenes-interview.json", import.meta.url), "utf8"))
const t = (text: string, x: number, y: number, w: number, h: number) => ({ text, box: [x, y, w, h], ink: [x + 10, y + 6, w - 20, h - 12], opacity: 1, size: 48 })
const man = (texts: unknown[]) => ({ width: 1080, height: 1920, fps: 30, frames: [{ frame: 0, text: texts }] })
// c: a woman sitting with her dog; the caption on the dog, the hook over the crowd behind her
const c = textOver(man([t("$1,000 for one vet visit?", 116, 236, 848, 112), t("He hurt his little", 290, 1335, 630, 90)]), [sc.c], 1)
assert.equal(c.length, 1, JSON.stringify(c))
assert.equal(c[0].level, "error")
assert.match(c[0].says, /“He hurt his little” covers a dog/)
const top = Number(/top (\d+) px/.exec(c[0].says)?.[1])
assert.ok(top >= 1380, `moved below the dog, not ${top}`)
ok("a caption over the dog is an error, moved to the clear ground under it; the hook over passers-by is fine")
// a: a checklist on a woman's lap, a sign under her, a man standing behind: no clear place for a block that size
const a = textOver(man([t("✓ 24/7 virtual vet care", 256, 1044, 568, 80), t("✓ Price-matched Rx", 280, 1130, 520, 76), t("✓ Free delivery", 336, 1214, 410, 76)]), [sc.a], 1)
assert.equal(a.length, 1, "the checklist's three lines are one block")
assert.match(a[0].says, /and the 2 lines under it\) covers a person in the shot/)
assert.match(a[0].says, /no place of its size is clear/)
ok("a checklist on a person is said once for its block, and that no place its size is clear")
// the clearest places for a caption in a: never on the sign, which is the ad's hook
const pa = placeReport("a.jpg", [sc.a], [840, 110])
assert.ok(pa.places.length >= 2)
assert.ok(!pa.places[0].covers.includes("words in the shot (a sign)"), JSON.stringify(pa.places[0]))
assert.ok(pa.places[0].top < 400, JSON.stringify(pa.places[0]))
ok("raea frames place keeps a caption off the sign in the shot")
// 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))
ok("a caption over a person who fills the frame is at most a warning")