Dynamic object aware egomotion

From XuShuwenn/RedAct · View interactive version

Dynamic object aware egomotion is an AI agent skill from the GitHub repository XuShuwenn/RedAct. Analyze video files for camera motion (egomotion) and detect dynamic objects, outputting motion labels and binary masks.

How to use this skill

Skill file

Dynamic Object Aware Egomotion Detection

When to Use

Completion Rule

Treat the task as incomplete until both output files exist at the required paths:

Do not stop at environment exploration, package inspection, frame extraction, or a written summary. Use reconnaissance only to unblock execution, then run the analysis and save the artifacts.

If the environment or task specifies a required runtime/tool-call protocol or exact completion string, follow it exactly.

Output Files

  1. /root/pred_instructions.json - Frame intervals to motion labels
  2. /root/pred_dyn_masks.npz - Binary masks for dynamic objects

Important indexing and coverage rules:

Motion Labels

Valid labels: Stay, Dolly In, Dolly Out, Pan Left, Pan Right, Tilt Up, Tilt Down, Roll Left, Roll Right

Format:

{
  "0->1": ["Pan Right"]
}

Use interval keys over sampled-frame positions, not raw frame IDs. If sampled frames are [0, 10, 20, 30] in the source video, transitions are keyed as "0->1", "1->2", "2->3" — not "0->10", "10->20".

Stay is mutually exclusive with all active motion labels; do not emit Stay together with Pan, Tilt, Roll, or Dolly for the same interval.

When compressing consecutive sampled-frame motions into intervals, ensure coverage spans the full sampled sequence, including the final sampled frame. Example: if 22 sampled frames all share one motion label, use "0->21".

Do not use a reduced classifier that can only emit pan/tilt/stay. The task label space includes Dolly In, Dolly Out, Roll Left, and Roll Right.

Before writing JSON, verify that interval keys use sampled-frame index space and that every label is one of: Stay, Dolly In, Dolly Out, Pan Left, Pan Right, Tilt Up, Tilt Down, Roll Left, Roll Right.

Mask Format (CSR Sparse)

For frame i, store in NPZ:

Index mask entries by sampled-frame position.

Implementation guardrails:

Key Parameters

Required Workflow and Done Criteria

Required Workflow and Done Criteria

  1. Read/sample the video at the target rate.
  2. Infer camera motion for sampled-frame intervals and write /root/pred_instructions.json.
  3. Detect dynamic objects for each sampled frame and write /root/pred_dyn_masks.npz in the required CSR key format.
  4. Treat frame extraction, sampling metadata, and environment inspection as preparation only; they are not task completion.
  5. If a run fails and you identify a fix, rerun after applying the fix; treat outputs from earlier failed runs as stale until regenerated successfully.

Tips

```python

flow = cv2.calcOpticalFlowFarneback(

prev_gray, next_gray, None,

pyr_scale=0.5, levels=3, winsize=15,

iterations=3, poly_n=5, poly_sigma=1.2, flags=0

)

```

Tips

Final Validation

Before declaring completion, open and inspect the deliverables, not just their file paths.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.