diff options
| author | Somhairle H. Marisol <[email protected]> | 2026-09-29 10:42:46 +0800 |
|---|---|---|
| committer | Somhairle H. Marisol <[email protected]> | 2026-09-29 10:42:46 +0800 |
| commit | c1857556fb4c0c3fd684b4261966f5f97ee2ba13 (patch) | |
| tree | ab955d1b952ae19bf2ef769a3ce407db8762cc2e /scripts/analyze-p72.py | |
| parent | 328760853c15c44d1de915d6c88e0dfd7ddc5af6 (diff) | |
| download | living-village-c1857556fb4c0c3fd684b4261966f5f97ee2ba13.tar.gz | |
p72: 补齐六帧行走证据(含 FrameTwo 独立抽帧)
analyze-p72 改为按帧各取像素相异的独立抽帧;docs/evidence 增 p72-walk-frametwo.png,framesix 换为独立帧。已 add 全部改动,工作树就绪,未 push。
Diffstat (limited to 'scripts/analyze-p72.py')
| -rw-r--r-- | scripts/analyze-p72.py | 49 |
1 files changed, 39 insertions, 10 deletions
diff --git a/scripts/analyze-p72.py b/scripts/analyze-p72.py index a9171e0..bd179ca 100644 --- a/scripts/analyze-p72.py +++ b/scripts/analyze-p72.py @@ -105,18 +105,47 @@ def main(): if mean > 75.0: world_pngs.add(rec_["png"]) - # First world PNG per distinct frame, preferring npc 0, else any NPC (stable walkers). + # Candidate world PNGs per frame: npc 0 first (stable walker), then other NPCs. + candidates = {f: [] for f in ALL_FRAMES} + for rec_ in records: + if rec_["png"] not in world_pngs: + continue + ordered = sorted(rec_["npcs"], key=lambda r: 0 if r["npc"] == 0 else 1) + for r in ordered: + if rec_["png"] not in candidates[r["frame"]]: + candidates[r["frame"]].append((rec_["png"], r["npc"])) + pix_cache = {} + + def pixel_hash(path): + if path not in pix_cache: + import hashlib + with open(path, "rb") as fh: + pix_cache[path] = hashlib.sha256(np.asarray(Image.open(path).convert("RGB")).tobytes()).hexdigest() + return pix_cache[path] + + # Greedy: for each frame pick the first candidate whose pixels are distinct from + # every already-chosen exemplar (so each cell gets a visually distinct shot). exemplar = {} - for want_npc in (0, -1): - for rec_ in records: - if rec_["png"] not in world_pngs: + used_pngs = set() + used_hashes = set() + for f in ALL_FRAMES: + choice = None + for png, npc in candidates[f]: + if png in used_pngs: + continue + if pixel_hash(png) in used_hashes: continue - for r in rec_["npcs"]: - if r["frame"] in exemplar: - continue - if want_npc == 0 and r["npc"] != 0: - continue - exemplar[r["frame"]] = (rec_["png"], r["npc"]) + choice = (png, npc) + break + if choice is None: + for png, npc in candidates[f]: + if png not in used_pngs: + choice = (png, npc) + break + if choice is not None: + exemplar[f] = choice + used_pngs.add(choice[0]) + used_hashes.add(pixel_hash(choice[0])) lines.append( "walk frame exemplars: " + ", ".join(f"{k}={Path(v[0]).name}(npc{v[1]})" for k, v in sorted(exemplar.items())) |
