Download tools/probe.py from AK51/MoonFlash: direct link, hf CLI and curl.
- Browser
- Download file 932 Bytes
-
https://huggingface.co/spaces/AK51/MoonFlash/resolve/main/tools/probe.py
- Command line
-
hf download hf://spaces/AK51/MoonFlash/tools/probe.py
-
curl -L -o probe.py https://huggingface.co/spaces/AK51/MoonFlash/resolve/main/tools/probe.py
932 Bytes
| import cv2, sys, numpy as np | |
| path = r"E:\test\Kiro_flash_detection\Video\0921 (1)_flash.mp4" | |
| cap = cv2.VideoCapture(path) | |
| if not cap.isOpened(): | |
| print("FAILED to open"); sys.exit(1) | |
| fps = cap.get(cv2.CAP_PROP_FPS) | |
| n = cap.get(cv2.CAP_PROP_FRAME_COUNT) | |
| w = cap.get(cv2.CAP_PROP_FRAME_WIDTH) | |
| h = cap.get(cv2.CAP_PROP_FRAME_HEIGHT) | |
| dur = n / fps if fps else 0 | |
| print(f"fps={fps} frames={n} size={w}x{h} duration={dur:.2f}s ({dur/60:.2f} min)") | |
| # The user says the flash is at 01:27:02 -> interpret as 1 min 27 sec (frame 02?) | |
| # Extract a window around 87s. | |
| for t in [86.5, 87.0, 87.08, 87.5, 88.0]: | |
| cap.set(cv2.CAP_PROP_POS_MSEC, t*1000) | |
| ok, frame = cap.read() | |
| if not ok: | |
| print(f"t={t}: read failed"); continue | |
| g = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) | |
| print(f"t={t:.2f}s frame~{int(t*fps)}: gray min={g.min()} max={g.max()} mean={g.mean():.1f} bright_px(>200)={int((g>200).sum())}") | |
| cap.release() | |