#!/usr/bin/env python3 """Check how much motion each joint video actually shows. Compares each frame against frame 0; fraction of pixels with abs diff > 30. """ import sys from pathlib import Path import imageio.v2 as imageio import numpy as np ROOT = Path(sys.argv[1] if len(sys.argv) > 1 else "/home/zhanghao/scene/scenesmith_full/outputs/demo") if ROOT.name.startswith("home_"): scenes = [ROOT] else: scenes = sorted(d for d in ROOT.iterdir() if d.is_dir() and d.name.startswith("home_")) moved_total, total = 0, 0 for sc in scenes: vd = sc / "joint_videos" if not vd.is_dir(): continue vids = sorted(vd.glob("*.mp4")) n_vis, n_ok = 0, 0 per = [] for v in vids: a = imageio.mimread(str(v)) f0 = a[0].astype(np.int16) best = 0.0 for f in a[1:]: d = np.abs(f.astype(np.int16) - f0).max(axis=2) best = max(best, float((d > 30).mean())) per.append((v.stem, best)) if best > 0.005: n_vis += 1 n_ok += 1 total += len(per) moved_total += n_vis vis = ", ".join(f"{s}:{m*100:.1f}%" for s, m in per if m > 0.005) print(f"{sc.name}: {n_vis}/{n_ok} visible motion {vis}") print(f"TOTAL: {moved_total}/{total} videos with visible motion")