Skip to content

Recording and Stills: One Video per Camera, Frames Picked by the Gyroscope

The robot stops at each pose of the camera path for a fraction of a second and moves on. The recording is one continuous video per camera. This page covers what is recorded, what is checked before any solving, and how one sharp frame per stop is found.

The camera of the case study sends both lenses side by side in one frame at 60 frames per second, and its H.264 stream carries the IMU samples inside the video (as SEI user data), about 10 samples per frame on the same clock as the frames. The MJPEG stream carries no IMU. So the cell records H.264: one file holds the pictures, the gyroscope, the accelerometer and their common clock.

In our experience, compression was not what limited accuracy. On rendered images with known truth, the whole chain run through MJPEG compression gave a projection within 0.014 px of the truth. Exposure was what mattered.

In our experience, light on the target is the cheapest accuracy there is. Without dedicated lights the camera needed 7 ms of exposure and frames taken while moving were blurred. With lights on the target the exposure went to 1.5 ms. One camera was recorded twice three minutes apart, first with the lights not yet set and then with them set:

Lights not set Lights set
Mean error, held-out, left / right lens 0.254 / 0.254 px 0.202 / 0.199 px
Mean error in the outer band of the lens 0.541 px 0.296 / 0.281 px
Predicted corners the image did not confirm 25.7 / 22.6 % 15.9 / 13.1 %

Lock the exposure by hand. This camera returns to automatic exposure every time it is plugged in, so the station sets the exposure again after each plug-in.

These are cheap and catch recordings that should not be solved at all. They are gates of their own.

Check Why
Dropped frames A gap in the frame numbers means the frame times cannot be trusted
IMU samples per frame Fewer than expected means samples were lost; in our recordings one sample went missing at a frame boundary about 24 times in 4 minutes, which is tolerated and counted
Time stamps always increasing A stream that restarts looks like one recording and is two
Frame rate and IMU rate A camera switched to 30 frames per second gives half the stills. The station measures the rate from the file being written and does not start the robot below 58
The recording file is growing A camera can drop off USB while the software still shows “recording”

The first still picker compared neighbouring frames and called a frame still when it did not change. In our experience, that fails on compressed video: static frames are bit-identical whether or not the camera has settled, and slow motion looks still, so blurred frames were picked and stops were missed.

The camera’s own gyroscope answers the question directly. A stop is a stretch where the rotation rate stays under 1 degree per second for at least 0.15 s, and the still is the frame nearest its middle. Three details mattered:

  • The gyroscope bias comes from the steadiest moments of the whole recording. Taken from the first seconds it was wrong whenever the robot was already moving, and on one long recording the picker then found no stills at all.
  • Not the first frame of a stop. The arm is still settling.
  • One recording, two parts. The robot runs the camera path, holds still at home for 4 seconds, then runs the swing path for the camera to IMU step. The picker finds the hold and gives stills only from the first part.
  • Inputs: the IMU samples and the frame times of one recording, on one clock; the gyroscope’s scale.
  • How to check: the number of stills equals the number of poses in the robot program; no still is blurred; on a recording whose first seconds are in motion the bias does not change when those seconds are left out.
Write the step that picks the still frames out of a calibration recording. The robot moves the
camera from pose to pose and stops briefly at each; the recording is one continuous video with the
camera's own IMU samples time-stamped on the same clock as the frames. I need exactly one sharp
frame per stop.
Why by the IMU and not by the pictures: in a compressed video two frames of a static scene are
bit-identical and slow motion looks still, so frame differences pick blurred frames and miss stops.
The gyroscope knows when the camera is not turning.
Inputs in this directory:
- `imu.csv`: time in seconds, gyro x, y, z in raw sensor counts, accelerometer x, y, z in raw
counts, about 600 samples per second. The scale is [8.192 counts per degree per second]. The gyro
has a constant bias that you must estimate from the data.
- `frames.csv`: frame index and time in seconds, 60 frames per second.
- The recording may contain two parts: first the stop-and-go camera path, then, after a hold of at
least 3 seconds at the home pose, a second part where the camera is moved continuously (it is used
for something else). Only the first part gives stills.
Write `pick_stills.py`:
- estimate the gyro bias from the steadiest moments of the WHOLE recording, not from the first
seconds: the robot may already be moving when the recording starts. Cut the recording into blocks
of about [0.2] s, keep the quietest tenth by their spread, and take the median of their MEANS (a
median of raw samples can only land on a whole sensor count);
- a stop is a stretch where the rotation rate (the length of the bias-corrected gyro vector,
smoothed over about [20] ms) stays under [1.0] degree per second for at least [0.15] s; join two
stretches separated by less than [30] ms; pick the frame nearest the middle of the stretch, never
the first or last frame of it (the arm is still settling at the start); a stretch cut off by the
start or end of the recording is not a stop;
- find the long hold that separates the two parts, if there is one. The hold itself gets no still.
Report the first frame after the hold as the start of the second part, and pick nothing after it;
- output `stills.json`: the picked frame indices and times, the bias, the number of stops, the split
point; and print a summary.
Then check yourself on `truth.json` (the true stop intervals of this recording): every true stop
must have exactly one pick inside it, with no picks outside any stop. Print the counts. If the first
seconds of the recording are in motion, show that your bias estimate is unaffected.

A fresh AI session got the prompt and a synthetic recording with known truth: 60 stops of 0.28 to 0.5 s with a settling wobble at the start of each, a first second in motion, a slow 2 degrees-per-second creep that is not a stop, a 4.2 s hold, then 40 s of continuous swinging. Its first attempt picked exactly one frame inside each of the 60 stops and nothing elsewhere, found the split within 1 ms, and estimated the bias to 0.06 degrees per second; with the median of block means, to 0.001. The wording about the bias, about joining stretches and about the hold was tightened from its notes.