"""Save the exact 8 frames DeCoF uses for key Veo videos for visual inspection.""" import os import sys import cv2 import numpy as np from pathlib import Path project_root = Path(__file__).parent sys.path.insert(0, str(project_root)) sys.path.insert(0, str(project_root / 'sdk')) import importlib.util spec = importlib.util.spec_from_file_location( 'decof_detector', project_root / 'models' / 'video' / 'DeCoF' / 'detector.py' ) module = importlib.util.module_from_spec(spec) sys.modules['decof_detector'] = module spec.loader.exec_module(module) # Videos to inspect: sunflower (FAKE), jellyfish, northern_lights, cowboy videos = { 'sunflower': 'D:/veo/veo/veo_example_041_sunflower.mp4', 'jellyfish': 'D:/veo/veo/veo_example_014_jellyfish.mp4', 'northern_lights': 'D:/veo/veo/veo_example_006_northern_lights.mp4', 'cowboy': 'D:/veo/veo/veo_cowboy_sun_1.mp4', } out_dir = project_root / 'decof_frames' out_dir.mkdir(exist_ok=True) detector = module.DeCoFDetector() print("=" * 70) print("Saving DeCoF frames for visual inspection") print("=" * 70) for name, path in videos.items(): print(f"\n[{name}] {os.path.basename(path)}") frames = detector._extract_decof_frames(path) print(f" Extracted {len(frames)} frames") # Save each frame for i, frame in enumerate(frames): # frame is RGB numpy array bgr = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR) fname = f"{name}_frame{i:02d}.jpg" fpath = out_dir / fname cv2.imwrite(str(fpath), bgr) print(f" Saved {len(frames)} frames to {out_dir}") print(f"\nAll frames saved to: {out_dir}") print("\nFrame indices (DeCoF protocol): 0, 4, 8, 13, 17, 22, 26, 31")