dyn-object-masks
Installation
SKILL.md
When to use
- Detect moving objects in scenes with camera motion; produce sparse masks aligned to sampled frames.
Workflow
- Global alignment: warp previous gray frame to current using estimated affine/homography.
- Valid region: also warp an all-ones mask to get
validpixels, avoiding border fill. - Difference + adaptive threshold:
diff = abs(curr - warp_prev); ondiff[valid]compute median + 3×MAD; use a reasonable minimum threshold to avoid triggering on noise. - Morphology + area filter: open then close; keep connected components above a minimum area (tune as fraction of image area or a fixed pixel threshold).
- CSR encoding: for final bool mask
rows, cols = nonzero(mask)indices = cols.astype(int32);data = ones(nnz, uint8)counts = bincount(rows, minlength=H);indptr = cumsum(counts, prepend=0)- store as
f_{i}_data/indices/indptr