# Consultant T-shirt logo re-bake (2026-10-03)

The consultant's chest logo is **painted into the film pixels**, not overlaid. The package's
`source/pipeline/logobake3.py` placed it one frame at a time with no tracking, so in
`beyond-a.mp4` and `connect-film.mp4` it jumped between the two sides of her chest, flickered off,
printed over her hair, and left the raw magenta chest marker showing (frames ~44–79 of beyond-a,
161–171 and 204 of connect-film). Owner report: *"the propertylab logo at the shirt got error"*.

These scripts redo that pass on the shipped films: track her upper body, erase every earlier print
and the marker, print one logo at one tracked spot, behind hair and hands. Output is live as
`beyond-a-v3.mp4` and `connect-film-v5.mp4` (new names: `/cinematic/assets/*` is cached immutable).

**v2 was wrong (same day, owner: *"the shirt surrounding like a lot blur square, the blur box square show at
the hair too"*).** Its erase step removed anything blue-ish, dark or pinkish in a wide box round the chest,
which caught hair edges, the skyline and the collar; each was refilled with a blurred patch. v3
(`rebake3.py`) erases ONLY: (1) old prints found by template match, (2) old prints the template misses —
a word-shaped cluster of print-coloured pixels ringed by white fabric (not inside a laptop frame, not on
blue sky), (3) the strictly-magenta marker and its fringe, (4) print-coloured pixels in a tight window
where the new print goes. Warm pixels (hair, skin) and long dark shapes (laptop bezels) are never erased.
Check a re-bake with a diff overlay of every changed pixel, not just crops of the logo.

**connect-film v5 (2026-10-04, owner: "why one is the logo in middle, then another one the logo goes to the
sleeve").** v4 centred only the seated shot; the standing shot still used the package's side-of-chest
position, so the logo jumped at the light-sweep changeover, faded out for ~8 frames and showed the magenta
marker. v5 pins the print to the **neckline in BOTH shots** (`connect-film.neckline.json` seated,
`connect-film.neckline-standing.json` standing; blended over frames 164–172) and keeps one print at full
strength through the changeover. Seated offset is 20 px left of the neckline centre so her hair no longer
clips the "B". Erase additions in `rebake4.py`: `abs` (absolute-pixel windows for stray fragments),
`abs_dark` (an old print lying over bare skin at the sleeve hem), an `inshirt` guard so the soft
"greyed letter" rule cannot bite an arm in cool light, and fabric-fill only for blobs ringed by fabric.
**Every frame 62–282 was reviewed as a contact sheet (`allcheck`-style crop round the print) before
shipping — do that, not spot checks; four earlier "fixed" claims each missed a part nobody looked at.**

**connect-film v4 (2026-10-04, owner: two logos while it moves, and the logo sat off to one side, "not a typical
logo location").** The seated meeting scene now prints the logo at the **centre of the chest, a fixed 35 px
(× scale) below the neckline** — the standing and walking scenes already sat there. Body tracking drifted
when she turned, so the position is pinned to the neckline instead: a template match of her neck + collar
from frame 110 (`connect-film.neckline.json`, scores 0.87–1.0). `rebake4.py` adds: `print_at` (absolute
position), `offset`/`width`, a laptop mask (everything below a wide flat dark edge under the print is in
front of her, so nothing prints over the screen), `force` windows that erase navy ink lying on the laptop
edge, and a harder erosion so letters touching the bezel are not mistaken for it.

Needs Python with `opencv-python-headless numpy`, ffmpeg, and the logo raster from the founder's
package (`source/brand/logo_tee.png`, passed as `LOGO=`). Work on extracted frames:
`ffmpeg -i film.mp4 -start_number 0 dir/f%03d.png`.

| Script | What it does |
|---|---|
| `track.py dir seed a0 a1 cx cy r out.json` | LK optical flow + RANSAC similarity, from a seed frame forwards and back, features inside a circle on her upper body |
| `traj.py track.json dir ax ay a0 a1 out.json` | anchor → per-frame x, y, scale, angle; where tracking is lost (blurred close-up) it anchors on the raw magenta marker; smooths |
| `plan.py '<json cfg>'` | connect-film: two tracked scenes cross-faded through the light-sweep morph (beyond-a's plan was built from `traj.py` output the same way) |
| `rebake4.py src dst plan.json` | connect-film v4: rebake3 + neckline pinning, laptop mask, `force` windows |
| `rebake3.py src dst plan.json` | the conservative erase above, refill from white fabric, print once behind hair/hands tinted by the light on the shirt |

What was run (frame indices are 0-based at 24 fps):

- **beyond-a**: `track.py ba 70 42 175 860 440 130`, `traj.py … 840 480 42 175`, logo width 80, rotation
  ×0.3 → `beyond-a.plan.json`; `LOGO=… rebake3.py ba out beyond-a.plan.json`.
- **connect-film**: seated scene tracked from frame 120 (anchor 480,560 — the left-chest spot clear of
  hair and laptop), standing scene from frame 230 (anchor 278,547, tighter radius 105 so the
  handshake does not drag it); the resulting plan is `connect-film.plan.json` (`marker_soft` on 160–172 for
  the washed-out marker under the light sweep; `extra`/`word` windows on 148–162 for an old print low left).
- Encode as the package does: `libx264 -preset slow -crf 20 -g 8 -keyint_min 8 -sc_threshold 0 -bf 0
  -pix_fmt yuv420p -movflags +faststart` (PSNR vs the original ≈ 40 dB outside the logo).

Known leftover: connect-film frames 62–65 have a pale smudge where the old marker / print sat on the purple
ribbon (4 frames of a fast sweep). The living-room shot (beyond-a 270+ / beyond-b 0–60) was already consistent and is
untouched.

## Hong Kong and Dubai films (2026-10-05)

The HK and AE packages shipped with the same faults the KL films had (logo on the side of the chest, the raw magenta
marker showing through the light sweep, stray prints on her arm and the wall for a few frames). Owner: *"fix to be
same like KL version"*. Live as `public/cinematic/{hk,ae}/assets/connect-film-v2.mp4` and `beyond-a-v2.mp4`;
`tools/apply_{hk,ae}.py` now point at the `-v2` names (new names because `/cinematic/*` is cached immutable).

A shorter route than the KL one, all pinned to the neckline:

| Script | What it does |
|---|---|
| `mkplan.py dir out.json '<shots>'` | per shot: template-match her neck + collar from a seed frame (scores 0.85–1.0), print at a fixed offset below it → a rebake plan |
| `rebake5.py src dst plan.json` | rebake4 + `old` rectangles (relative to the new print: where the package's print and marker sat — everything there that is not fabric is erased, hair kept, including hair turned purple by the light sweep) and `pink` (marker remnants on hair edges) |
| `strays.py dir plan a0 a1 [score]` | removes stray copies of the logo printed off the shirt (HK connect-film 85–89), by template match at half size |
| `patch.py dir '{frame:[[x0,x1,y0,y1]]}'` | hand-listed leftovers: inpaint what is darker than its surroundings in a rectangle |

The shot definitions are in `hk-ae/shots_*.json` (seed frame, collar template, print centre and width, old-print
rectangle), the hand patches in `hk-ae/patch_*.json`. Run: `mkplan` → `rebake5` → (`strays` 82–92 at 0.74 then 84–89
at 0.6 for HK connect-film) → `patch` → encode as above. Every re-baked frame was reviewed on a contact sheet.

Left alone: AE beyond-a's living-room shot (frames 268+) — she stands in profile and the package's print there is
steady on the front of her chest. The white rectangle visible beside the print in a few AE connect-film frames
(172–187) is the package's own erase patch, under the new fill.
