Skip to content

C203 Prompts: AI Assistant Prompts for Syncing Cameras Across Devices

These prompts hand one practical job each to an AI assistant (Claude, ChatGPT, Gemini or another). Paste your own files and values where the square brackets are. Each prompt states what it needs, which tool it targets, how to check what comes back, and the field guide page whose facts it relies on.

An assistant can get a sign convention backwards or invent a tolerance as easily as a person can. The prompts tell it not to, and every one ends with a check you run yourself. Treat the output as a draft until that check passes.

  • Inputs: your device list from lab step 1: each device’s clock, what its timestamps mark, and what it supports.
  • Tool: none; a written plan.
  • Relies on: How to choose and Six patterns in published rigs.
  • How to check: every device has a method, every method appears in the field guide’s comparison table, and every device also gets a start and end event.
Plan time sync for my capture set-up. For each device I give its clock, what its
timestamps mark (start of exposure, mid-exposure, end of readout, or arrival at a
computer), and what it supports (trigger input or strobe output, Ethernet with hardware
timestamping, timecode input, GoPro Labs firmware, or none).
[device list]
Use only these rules:
- Sensors on one rig that can be wired: hardware sync, one trigger and one clock for
cameras and IMU, exposure times recorded so midpoints can be computed.
- Separate devices I control: clock sync during the recording (PTP on Ethernet,
NTP/chrony otherwise, timecode where a device has an input). Clock sync aligns clocks,
not exposures.
- Cameras I cannot modify: an event at the start and end of every recording.
- Every device: a start and an end event anyway, because one sync point cannot measure
drift.
Give one row per device with its method and why. Do not recommend adding, removing or
re-aiming cameras, and do not invent accuracy figures; where a figure matters, say which
test from the field guide would measure it.
  • Inputs: one CSV per camera from ffprobe ... signalstats -show_entries frame=pts_time:frame_tags=lavfi.signalstats.YAVG -of csv=p=0 (lab step 7).
  • Tool: Python.
  • Relies on: Light flashes.
  • How to check: open the frames the script reports in a video player and confirm the light changes there; run it on a clip with no flash and confirm it reports none.
Write a Python script that reads one CSV per camera, each line "pts_time,YAVG" (frame
time in seconds, average luma 0-255), from footage in which a light was switched on and
off several times near the start and near the end of a recording. For each camera, find
each on and off switch as the frame where the brightness steps, using the frame-to-frame
difference of YAVG; take the step threshold as a required command-line argument, with no
default. Report each switch's frame time per camera, match the switches across cameras
by order, and print each camera's offset to a reference camera at the start and at the
end. Warn if the cameras show different numbers of switches, and plot each camera's YAVG
with the detected switches marked.

Decode QR timestamps and fit offset and drift

Section titled “Decode QR timestamps and fit offset and drift”
  • Inputs: one video per camera, each filming a screen that shows the current time as a QR code near the start and the end.
  • Tool: Python with PyAV and OpenCV.
  • Relies on: Decode QR timestamps and estimate offset and drift (this prompt is adapted from the one there) and Accuracy limits.
  • How to check: decode a few frames by eye and compare; the script must warn when one end has no readings, and the drift it reports should be of the size crystals are rated for.
Write a Python script that takes several video files, one per camera. Each video shows a
screen with a QR code encoding the current time in milliseconds since the Unix epoch,
near the start and near the end of the recording. For every frame: read the frame's
presentation timestamp from the container (use PyAV; do not use frame index times
nominal period), decode any QR code with OpenCV's QRCodeDetector, and record
(frame_time, qr_time). Skip frames where decoding fails. For each camera, fit
qr_time = a * frame_time + b with a robust fit (RANSAC or Huber), report the offset b in
ms, the drift (a - 1) in parts per million, the residual standard deviation, and the
number of readings at each end. Warn if only one end has readings, because then drift
cannot be measured. Write a CSV mapping every frame of every camera to the common time
base. Plot the residuals per camera.

Check my recordings for dropped and duplicated frames

Section titled “Check my recordings for dropped and duplicated frames”
Write a Python function that takes one camera's frame timestamps in seconds (from
ffprobe best_effort_timestamp_time, or from the device) and recovers each frame's
exposure number, following Akhmetyanov et al. (2021): shift so the first timestamp is
zero, set tau_init to the smallest positive interval, set N_i = floor(t_i / tau_init +
0.5), then estimate the period tau by least squares on the intervals against
N_i - N_(i-1). Iterate once with the new tau. Report tau, the frame rate, every place
where N jumps by more than 1 (dropped frames), any repeated N (duplicated frames), any
timestamps that go backwards, and the residual standard deviation. Test it on synthetic
30 fps timestamps with Gaussian noise and a few frames removed.

Convert device timestamps from two sync points

Section titled “Convert device timestamps from two sync points”
I have two sync events per recording. At each event I know the time on a reference clock
and the time on a device clock. Write a small Python function that computes the offset
and the drift in parts per million between the two clocks, then converts any device
timestamp to reference time by linear interpolation (and extrapolation outside the two
events, with a warning). Include unit tests using this example: the device is 1240 ms
ahead at the start and 1312 ms ahead 60 minutes later, which should give 20 ppm and an
offset of 1276 ms at 30 minutes. Then apply it to every frame time in [frames.csv] and
write a new column with the reference time, keeping the original column unchanged.

Flag takes with bad clock sync from PTP logs

Section titled “Flag takes with bad clock sync from PTP logs”
  • Inputs: the ptp4l -m and phc2sys -m logs from a session, and a CSV of take start and end times.
  • Tool: linuxptp logs, Python.
  • Relies on: Reading the logs and Flag takes with bad clock sync (this prompt is adapted from the one there).
  • How to check: a take during which you unplugged a cable or restarted ptp4l on purpose must be flagged.
Write a Python script that parses logs from `ptp4l -m` and `phc2sys -m` recorded during
a capture session, plus a CSV of take start and end times. Handle both log forms
phc2sys can print: individual samples (the default) and summary lines with rms and max
(when run with -u). Extract the offset (ns), frequency (ppb) and delay over time, and
every ptp4l port state change. For each take, report the RMS and maximum absolute
offset and any state change, and flag takes whose maximum offset exceeds a threshold
given on the command line, with no default. Save one plot per take.
  • Inputs: a video in which an LED clock of the RocSync kind is shown near the start and the end, and the board’s layout.
  • Tool: Python with OpenCV and PyAV.
  • Relies on: The RocSync LED clock and Decode an LED clock (this prompt is adapted from the one there).
  • How to check: for a few frames, read the counter and the lit arc by eye and compare with the script; the exposure lengths it reports should match the camera’s exposure setting.
Write a Python script with OpenCV that decodes an LED sync clock in the first and last
20 seconds of a video. The board has a central ArUco marker (dictionary and ID given as
arguments), four corner LEDs at known board coordinates, a 16-LED binary counter that
counts 100 ms steps, and a ring of 100 LEDs, one lit per millisecond. For each frame:
detect the marker, reject the frame if it covers less than 0.2% of the image, rectify
the board with a homography from the marker and then from the corner LEDs, threshold
each LED, and reject frames where the ring shows more than one lit arc or the arc
crosses the 99-to-0 wrap. Convert the first lit LED and the counter to a clock time in
ms, and the arc length to an exposure time. Read each frame's presentation timestamp
from the container with PyAV. Fit clock_time = alpha * pts + beta with RANSAC and report
offset, drift in ppm, residuals and the number of frames used at each end.

Interpolate hand keypoints to a common time

Section titled “Interpolate hand keypoints to a common time”
I have 2D hand keypoints (21 per hand) per frame from several cameras, each frame with a
timestamp already mapped to a common clock, plus calibrated projection matrices. Write a
Python function that, for a list of target times, linearly interpolates each camera's
keypoints between the two frames that bracket the target time (skip a camera if either
frame is missing a detection or the gap is longer than 1.5 frame periods), then
triangulates each joint with DLT from the cameras that remain and reports the
reprojection error per joint. Compare against using each camera's nearest frame.