360 Secure SkillHub
360 安全技能中心

sampling-and-indexing

提供视频采样与帧索引的规范流程:读取视频帧数、fps 与分辨率,选择采样步长生成 sample_ids,并要求区间指令、掩码等下游产物共用同一索引体系与区间键格式,附带 Python/OpenCV 伪代码与自检清单。未包含可直接执行的脚本文件与掩码生成实现。

wu-uk
wu-uk
热度 36.05
最近更新 2026-05-11 17:43:10
分类:效率依赖:代码执行 / 读写文件应用场景:数据处理 / 工作流 / 自动化脚本

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add dynamic-object-aware-egomotion-sampling-and-indexing
Metadata
name
sampling-and-indexing
description
Standardize video sampling and frame indexing so interval instructions and mask frames stay aligned with a valid key/index scheme.

When to use

  • You need to decide a sampling stride/FPS and ensure all downstream outputs (interval instructions, per-frame artifacts, etc.) cover the same frame range with consistent indices.

Core steps

  • Read video metadata: frame count, fps, resolution.
  • Choose a sampling strategy (e.g., every 10 frames or target ~10–15 fps) to produce sample_ids.
  • Only produce instructions and masks for sample_ids; the max index must be < total_frames.
  • Use a strict interval key format such as "{start}->{end}" (integers only). Decide (and document) whether end is inclusive or exclusive, and be consistent.

Pseudocode

import cv2
VIDEO_PATH = "<path/to/video>"
cap=cv2.VideoCapture(VIDEO_PATH)
n=int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
fps=cap.get(cv2.CAP_PROP_FPS)
step=10  # example
sample_ids=list(range(0, n, step))
if sample_ids[-1] != n-1:
    sample_ids.append(n-1)
# Generate all downstream outputs only for sample_ids

Self-check list

  • sample_ids strictly increasing, all < total frame count.
  • Output coverage max index matches sample_ids[-1] (or matches your documented sampling policy).
  • JSON keys are plain start->end, no extra text.
  • Any per-frame artifact store (e.g., NPZ) contains exactly the sampled frames and no extras.