diff options
Diffstat (limited to 'design/motion/motion.py')
| -rw-r--r-- | design/motion/motion.py | 51 |
1 files changed, 37 insertions, 14 deletions
diff --git a/design/motion/motion.py b/design/motion/motion.py index b0647d7..d192295 100644 --- a/design/motion/motion.py +++ b/design/motion/motion.py @@ -26,6 +26,7 @@ SOFT = 6 # ... and is fading if by more than this MIN_PX = 12 # a region is moving in a frame if this many of its pixels moved MIN_SOFT = 150 # ... and fading if this many did: under it is the codec HOLD = 0.4 # seconds of nothing that count as a hold +STILL = 12 # frames still before a one-frame change counts as a pop def cols(first, n, y, h): @@ -46,6 +47,10 @@ REGIONS = { "boundary": (0, 528, W, 96), "kernel": (0, 624, W, 272), "caption": CAPTION}, "zoom": {"head": HEAD, "source": cols(0, 5, 0, 384), "registers": cols(0, 5, 408, 360), "stack": cols(5, 7, 0, 768), "caption": CAPTION}, + # The working frame (README.md, "The frame"): the two columns, the caption's text alone (not the clock's count + # at its right, which changes every step), the clock, the minimap. The default for any other name. + "frame": {"program": (64, 48, 880, 840), "state": (976, 48, 880, 840), "caption": (64, 906, 1400, 126), + "clock": (64, 894, 1600, 52), "minimap": (1664, 906, 192, 120)}, } PALETTE = ["#9aa6d9", "#e8c46a", "#6fd6e6", "#7fdc9a", "#d59cf5", "#ff6a4a", "#eee6d2", "#17a0b0"] @@ -90,7 +95,7 @@ def font(size): def regions_for(video, name): stem = os.path.splitext(os.path.basename(video))[0] - return REGIONS.get(name or stem, REGIONS["bands"]) + return REGIONS.get(name or stem, REGIONS["frame"]) # ---- measure -------------------------------------------------------------- @@ -182,7 +187,7 @@ def report(video, names, counts, soft, sizes, fps): return ev, "\n".join(lines) -WORDS = ("head", "caption") # regions that are not panels +WORDS = ("head", "caption", "clock", "minimap") # regions that are not panels def lint(names, counts, soft, sizes, fps, ev): @@ -193,10 +198,19 @@ def lint(names, counts, soft, sizes, fps, ev): on = busy(counts, soft) panels = [k for k, n_ in enumerate(names) if k > 0 and n_ not in WORDS] - # POP: a lot changes in a frame or two, with stillness either side: nothing eased it. - pops = [e["from"] / fps for e in ev if e["moved"] <= 2 and e["frames"] <= 3 and e["peak"] / sizes[0] > 0.002] + # POP: a region still for STILL frames changes in one frame and is still again, at any size: a label + # swapped, a box gone, a count appearing. Nothing eased it. (And, as before, a large change in two.) + pops = {e["from"] for e in ev if e["moved"] <= 2 and e["frames"] <= 3 and e["peak"] / sizes[0] > 0.002} + for k in range(1, len(names)): + if names[k] == "clock": # its count changes in a frame by design: it is time, not a thing + continue + col = on[:, k] + for t in range(STILL, len(col) - 1): + if col[t] and not col[t + 1] and not col[t - STILL:t].any() and counts[t, k] >= MIN_PX: + pops.add(t) + pops = sorted(pops) if pops: - out.append(f" POP {len(pops):3d} a change of over 0.2% of the frame in a frame or two: {some(pops)}") + out.append(f" POP {len(pops):3d} a change in one frame after stillness: {some([t / fps for t in pops])}") # CROWD: three or more panels begin to move within two frames of each other. crowd = [] @@ -221,18 +235,27 @@ def lint(names, counts, soft, sizes, fps, ev): for a, b, n_, gap in runs_: out.append(f" METRONOME {n_:3d} events {gap:.2f} s apart, from {a:.2f} to {b:.2f}") - # RUSH: a caption arrives or changes, and the picture moves before it can be read. + # CAPTION: a caption up too long or too short to be read, or the picture moving before it can be. + # Its time on screen is from the end of the change that brought it to the start of the next change. + # Without the text, the shortest is 90 f; tools/chart.py, which has the scene's captions, adds 3.6 f a + # character. The picture may move 60 f after a caption arrives, no sooner. cap = names.index("caption") if "caption" in names else None - rush = [] + late, longs, shorts = [], [], [] if cap is not None: - for a, b in runs(on[:, cap]): - if b - a < 3: - continue + changes = [(a, b) for a, b in runs(on[:, cap]) if b - a >= 3] + for (a, b), nxt in zip(changes, changes[1:] + [(len(on), len(on))]): + up = nxt[0] - b - 1 + if up > 720: + longs.append(b / fps) + elif 6 < up < 90: # 6: a caption leaving and the next arriving + shorts.append(b / fps) later = np.nonzero(on[b + 1:, panels].any(axis=1))[0] - if len(later) and later[0] / fps < 1.0: - rush.append(b / fps) - if rush: - out.append(f" RUSH {len(rush):3d} the picture moves within a second of a caption arriving: {some(rush)}") + if len(later) and later[0] < 60 and up >= 90: + late.append(b / fps) + for what, times in (("up over 720 f (12 s)", longs), ("up under 90 f", shorts), + ("the picture moves within 60 f of its arrival", late)): + if times: + out.append(f" CAPTION {len(times):3d} {what}: {some(times)}") # AIR: nothing at all changes for three seconds. air = [(a / fps, (b - a + 1) / fps) for a, b in runs(~on[:, 0]) if (b - a + 1) / fps >= 3.0] |
