Shapes, color, and time field card
The compact frame and timeline checks that prevent silent media bugs.
Use this card at every decode, metric, model, and save boundary. Write the answers beside the code; do not keep them in your head.
Array contract
- Shape: image
H × W × C; clipT × H × W × C; model image oftenC × H × W. - Axis meaning: name time, height, width, and channel explicitly.
- Dtype and range:
uint8 0..255or float with a declared range such as0..1. - Ownership: a slice may be a view; use
.copy()before isolated annotation. - Arithmetic: convert to a wider or floating dtype, then clip before conversion back.
Runtime: Browser lab · Pyodide with NumPy · 5 min.
import numpy as np
frame = np.zeros((1080, 1920, 3), dtype=np.uint8)
print(frame.shape, frame.dtype, float(frame.min()), float(frame.max()))
Color contract
- Pillow: ordinarily RGB.
- OpenCV decode: ordinarily BGR.
- Grayscale: record the conversion rule rather than saying “black and white.”
- Saved output: confirm the consumer’s expected color order.
- Blue/orange swaps are a contract clue, not a grading tweak.
Timeline contract
- Record duration, time base, stream/frame rate fields, and tool version.
- Prefer presentation timestamps for evidence-sensitive sampling.
- State uniform, boundary-aware, or event-driven sampling policy.
- Keep ordered timestamps beside extracted frame filenames.
- A nominal fps does not prove constant presentation cadence.
Five boundary questions
- What exact data entered?
- What are its shape, axes, dtype/range, and color order?
- Which timestamp or sampling rule selected it?
- Does this operation share or own memory?
- What inspectable evidence leaves the boundary?
Notes
Your local study notes mount here when JavaScript is available.
Protected AI Tutor
Teaching modes mount here when JavaScript is available. The readable course remains available without them.