dyn-object-masks
Generate per-sampled-frame dynamic-object binary masks (motion-compensated) and save them in CSR sparse format to an NPZ.
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-14
- Stars
- ★ 0
- Forks
- 1
01 前言 Front Matter
- name
- dyn-object-masks
- description
- Generate per-sampled-frame dynamic-object binary masks (motion-compensated) and save them in CSR sparse format to an NPZ.
03 SKILL.md 正文
Steps
- For each sampled frame index
i(0..S-1), read/computecurr_gray(H×W). - For
i==0, set the dynamic mask to all-False (no previous frame to compare), and encode/save it. - For
i>0, global alignment: warpprev_grayinto the current frame using the estimated transformM_{i-1→i}(affine or homography). - Compute a valid region by warping an all-ones mask with the same transform; only score differences where
valid==Trueto avoid border fill artifacts. - Compute
diff = abs(curr_gray - warped_prev_gray)and choose a robust threshold fromdiff[valid](e.g.,median + 3×MAD, with a minimum floor to avoid noise). - Build a raw foreground:
raw = (diff > thr) & valid, then postprocess with morphology (open then close). - Remove small connected components (area threshold) to suppress flicker/noise.
- CSR encoding (True pixels only) for final
mask(bool, H×W):rows, cols = np.nonzero(mask)indices = cols.astype(np.int32)data = np.ones(indices.size, dtype=np.uint8)counts = np.bincount(rows, minlength=H).astype(np.int32)indptr = np.concatenate([[0], np.cumsum(counts)]).astype(np.int32)- Store keys
f_{i}_data,f_{i}_indices,f_{i}_indptr
- Store
shape = np.array([H, W], dtype=np.int32)once in the NPZ and write/root/pred_dyn_masks.npz.
Expected Result
/root/pred_dyn_masks.npz contains shape=[H,W] and, for every sampled frame index i, valid CSR triplets f_{i}_data/indices/indptr that represent the binary dynamic mask for that sampled frame.
04 同仓库更多 Skills
video-frame-extraction
Extract frames from video files and save them as images using OpenCV
openai-vision
Analyze images and multi-frame sequences using OpenAI GPT vision models
image-ocr
Extract text content from images using Tesseract OCR via Python, including structured field extraction from receipts and forms
video-frame-extraction
Extract frames from video files and save them as images using OpenCV
openai-vision
Analyze images and multi-frame sequences using OpenAI GPT vision models
image-ocr
Extract text content from images using Tesseract OCR via Python, including structured field extraction from receipts and forms