跳转到内容

卷帘快门标定

当前的头戴采集设备在用于几何的相机上避开了这个问题:RoboCap、Ego-OSCAR 以及 Ego-1K 采集设备上的 12 台相机都是全局快门(见全局快门与卷帘快门)。卷帘快门传感器还留在两类地方。混合式的头显和眼镜把全局快门的跟踪相机与一台卷帘快门的 RGB 相机搭配使用;Ego-1K 采集设备里的 Quest 3 录制 “two forward-facing rolling-shutter RGB cameras”(意为:两台朝前的卷帘快门 RGB 相机)(Lee 等,2026),Project Aria 的 RGB 相机也是卷帘快门。运动相机和手机则全部是卷帘快门。

这些相机中任何一台如果用于几何、跟踪或 3D 重建,都需要标定它的读出时序。本页讲如何测量它以及如何使用它。卷帘快门是什么、已发表的读出时间、卷帘快门在什么情况下够用,见全局快门与卷帘快门;它对普通标定的影响,见破坏标定的镜头效应。

量 含义
行延迟 d(行时间) 一行开始曝光到下一行开始曝光之间的时间。Kalibr 把它存为 line_delay,单位是秒每行
读出时间 行延迟乘以行数:从第一行到最后一行的时间
扫描方向 读出在图像上沿哪个方向进行。旋转 90° 安装的传感器沿图像的列读出
参考行 帧时间戳指的是哪一行:通常是第一行,有时是中间行
像素时间 t(u) 像素 u 的拍摄时间:帧时间加上行号 × 行延迟
Global shutter and rolling shutter timing Two timing charts with sensor rows down the side and time running left to right. Global shutter: every row's exposure bar starts and ends at the same moments, so the whole image shows one instant. Rolling shutter: each row's exposure bar starts a row time, t_row, after the row above, so the bars form a staircase. Every bar has the same length, the exposure time, which sets motion blur within a row. The readout time, from the first row to the last, equals t_row times the number of rows and sets the skew between the top and bottom of the image, whatever the exposure time. Global shutter Rolling shutter exposure time exposure time every row exposes over the same interval each row starts t_row after the row above t_row readout time = t_row × number of rows top rowbottom row top rowbottom row timetime
Exposure timing, row by row. A global shutter exposes every row over the same interval. A rolling shutter starts each row a row time (t_row) after the one above, so the last row is read a whole readout time (t_row × number of rows) after the first. Exposure time sets blur within a row; readout time sets skew across the frame, so a short exposure does not fix a rolling shutter.

行延迟的两个性质决定了下面每一种方法:

  • 它属于传感器的一种模式,而不是属于一台相机。分辨率、裁切、像素合并(binning)和帧率都会改变它。Charmant 在测量一个网络摄像头时指出,把图像缩小不改变时序,但 “Cropping will change the scan time as there really are less pixels to read out”(意为:裁切会改变扫描时间,因为要读出的像素确实变少了)(Charmant,2015)。对你录制时用的每种模式都要标定。
  • 它有上限。在连续视频中,一帧的读出不能比帧周期更长,所以 d ≤ 1 / (fps × rows)。Oth 等人的估计正是从这里开始的:他们 “assume a zero frame-delay to initialise the line delay”(意为:假定帧延迟为零来初始化行延迟),取 d0 = 1 / (fps · NR),其中 NR 是传感器的行数(Oth 等,2013)。测得的行延迟如果超过这个上限,就是错的。

Oth 等人的手机结果显示了真实相机离这个上限有多近(Table 3):

手机,模式 测得的行延迟 读出时间(行数 × d) 30 fps 时的帧周期
iPhone 3GS,640 × 480 64.41 µs(σ 0.11) 30.9 ms 33.3 ms
iPhone 4S,1920 × 1080 24.12 µs(σ 0.52) 26.0 ms 33.3 ms
Galaxy S3,1920 × 1080 30.25 µs(σ 0.68) 32.7 ms 33.3 ms

读出时间一列是我们用论文的行延迟乘以行数得到的。

先检查相机是否已经报告了它的时序。

  • GoPro。GPMF 元数据轨道带有 SROT,即 “Sensor Read Out Time”(意为:传感器读出时间),在 HERO7 上逐帧记录,之后 “this moves to a global value in HERO8”(意为:在 HERO8 中它变成了一个全局值)(gpmf-parser)。把它除以该模式的行数就得到行延迟。用于采集的 GoPro 设置见运动相机。
  • Android 手机。Camera2 API 在每个拍摄结果中报告 SENSOR_ROLLING_SHUTTER_SKEW,即 “Duration between the start of exposure for the first row of the image sensor, and the start of exposure for one past the last row of the image sensor”(意为:从图像传感器第一行开始曝光,到最后一行的下一行开始曝光之间的时长)(Android CaptureResult 参考)。某一款手机是否准确地填写了它,值得用下面的某种方法检查。录制应用和手机设置见用于采集的智能手机。
  • 研究眼镜。Project Aria 把它的各传感器记录在 “on a common clock at nanosecond resolution”(意为:一个纳秒分辨率的公共时钟上),Lv 等人给出它的全分辨率 RGB 相机有 “a readout time of approximately 16 ms”(意为:约 16 ms 的读出时间)(Lv 等,2025)。

方法 2:一次短闪光,按条纹测量

Section titled “方法 2:一次短闪光,按条纹测量”

Charmant 的方法每帧用一次短闪光。一块 Arduino 让扩散片后面的 LED 闪光,定时使得 “exactly one flash happens for each captured frame”(意为:每拍摄一帧恰好发生一次闪光)。只有闪光亮起时正在曝光的那些行才能拍到它,所以闪光表现为一条亮的条纹。“We limit the flash duration to reduce the stripe of rows catching it, and we measure the height of the stripe in pixels.”(意为:我们限制闪光时长以缩小拍到闪光的行所形成的条纹,并以像素为单位测量条纹的高度。)

一行的曝光窗口只要与闪光有任何重叠,这一行就拍到了闪光,所以条纹覆盖的是曝光时间加上闪光时长:

line delay = (exposure + flash duration) / stripe height in rows

该文章中的实用要点:

  • 设置相机允许的最短曝光:“300 µs on the Logitech C920”(意为:在 Logitech C920 上是 300 µs)。
  • 调整闪光间隔,直到条纹不再移动。相机的真实帧率并不正好等于标称值:“The stripe stabilized when I settled on 33376 µs”(意为:当我定在 33376 µs 时条纹稳定了),而 30 fps 对应的是 33333 µs。
  • 用一颗大的 LED 和一片靠近镜头的扩散片把整行均匀照亮,这样条纹的边缘才清晰。
  • 用几种闪光时长重复测量。Charmant 用了 500、1000 和 2000 µs,平均得到每行约 56.6 µs,对 800 × 600 模式来说就是 “a 34 ms lag between the top and bottom rows”(意为:顶行和底行之间有 34 ms 的滞后)(Charmant,2015)。

这种方法需要准确知道曝光时间,而便宜的相机并不总能做到这一点。该文章指出,驱动程序的曝光属性 “does not always map precisely to the firmware values”(意为:并不总是精确地对应固件中的值)。

方法 3:一颗闪烁的 LED,按条带计数

Section titled “方法 3:一颗闪烁的 LED,按条带计数”

一盏闪烁得比帧率快得多的灯会留下明暗交替的条带;频率已知时,数条带的数量就得到读出时间(Gyroflow)。算法和一个算例见全局快门与卷帘快门。

Reading the row time from LED bands A rolling-shutter frame of 1080 rows filming an LED that blinks at a known 1 kHz with a short exposure. Because each row is read a little later than the one above, the LED's on and off periods appear as alternating bright and dark horizontal bands down the frame. A bracket marks a measured span of 820 rows that holds 11.5 complete on-off cycles. The row time is t_row = k divided by (f times delta-y) = 11.5 / (1000 times 820) = 14.02 microseconds per row; the readout time is 14.02 microseconds times 1080 rows = 15.15 ms; Kalibr's line_delay is 1.402e-05 s per row. The counts are invented for the example. Counting over more rows makes a half-band miscount at the edge a smaller error. one frame, 1080 rows Δy = 820 rows k = 11.5 cycles rows read top to bottom, one t_row apart LED blinks at f = 1 kHz (one on–off cycle every 1 ms) t_row = k ÷ (f × Δy) = 11.5 ÷ (1000 × 820) = 14.02 µs per row readout = 14.02 µs × 1080 = 15.15 ms Kalibr line_delay = 1.402e-05 s Counts invented for the example. Count over many rows: a half-band miscount then matters less.
Counting LED bands to measure a rolling shutter. Rows are read one t_row apart, so an LED blinking at a known frequency f paints alternating bands down the frame; k cycles across Δy rows gives t_row = k ÷ (f × Δy), and the readout time is t_row times the row count. The numbers are the invented worked example on Global vs Rolling Shutter. Use the shortest exposure, so the bands stay sharp.

OpenDroneMap 的 rscalibration 把它做成了一套套件。它的 Raspberry Pi Pico 版本用硬件定时器翻转 LED,timer.init(freq=1000, mode=Timer.PERIODIC, callback=blink),所以每条亮带或暗带持续 1 ms:“Each line will represent ~1ms of time”(意为:每条线代表约 1 ms 的时间),亮线和暗线合计的条数近似等于以毫秒为单位的读出时间。README 的示例图像大约有 25 条线,即约 25 ms。它对相机的建议:使用 “fastest shutter speed setting available”(意为:可用的最快快门速度设置),以及 “For cameras with non-Global Mechanical Shutters please try to force Electronic Shutter mode to ensure accurate readings.”(意为:对于带非全局机械快门的相机,请尽量强制使用电子快门模式,以确保读数准确。)

只有曝光比闪烁周期短,条带才分辨得出来。让光充满画面的整个高度,或者在一段量过的行数范围内计数再按比例放大。

当几台卷帘快门相机必须同步到远小于一帧的精度时,一颗 LED 就不够了。Nazarenus 等人为三台以 400 Hz 运行的 GoPro Hero 13 Black 相机做了一块板(Nazarenus 等,2026):

  • 一块 ESP32 微控制器驱动 21 个输出引脚:五个按顺序切换 LED 灯条,十六个驱动一个帧计数器。
  • 计数器用 15 颗白色 LED 以 “in Gray code”(意为:格雷码)显示帧号,格雷码从一帧到下一帧只有一位发生变化;另加一颗 LED “to resolve the inherent ambiguity of the Gray code”(意为:用来消除格雷码固有的歧义)。
  • 当一条灯条在画面的中途点亮或熄灭时,边界所在的行给出了时间。精度等于边界检测精度乘以行时间:行时间约 3 µs、边界定位在 5 px 以内时,约为 15 µs。

对他们的装置,作者观测到的行读出时间是 2.85 µs。用这块板做相机到相机的同步,见软件同步与视觉同步。

方法 5:从拍摄运动标定板的视频中求出

Section titled “方法 5:从拍摄运动标定板的视频中求出”

不需要额外硬件:在标定板前移动相机,让求解器找出使标定板角点对齐的行延迟。Oth 等(2013)提出了这种方法(论文 PDF),Kalibr 把它实现为 kalibr_calibrate_rs_cameras。

模型。时间戳为 t̄ 的一帧中位于第 v 行的角点,拍摄于 t = t̄ + v·d。相机的轨迹是一条连续时间 B 样条,所以可以在每个角点自己的时刻计算相机位姿。Oth 等人使用 “a 4th order B-spline as it is the first form which describes a continuous, jump-less motion”(意为:4 阶 B 样条,因为它是能描述连续、无跳变运动的第一种形式),并把样条和 d 一起求解。

论文中的流程。先求内参和畸变,用静止图像做普通标定:“To prevent RS distortions, the camera was kept still but not mounted to a fixed stand.”(意为:为防止卷帘快门畸变,相机保持静止,但没有安装在固定支架上。)然后从相机在图案前运动的 30–60 s 视频中估计行延迟。

节点很重要。样条的灵活程度由它的节点(knot)数量决定。太少就跟不上运动;太多就会拟合噪声,行延迟也跟着跑偏。在他们的测试中,“the line delay estimate stabilises between 600 and 1000 knots but then begins to diverge as more knots allow the curve to over fit.”(意为:行延迟估计在 600 到 1000 个节点之间稳定下来,但随后开始发散,因为更多的节点让曲线过拟合。)论文的解决办法是只在需要的地方加节点:从过少的节点开始,当某一段样条的代价 Jⱼ 超过它的误差项数量 Nⱼ 的两倍时,就把这一段拆分;Nⱼ 是在运动被完全解释的情况下白化残差之和应有的值。

精度如何。在一台可以根据规格书算出行延迟的机器视觉相机上,他们在四种像素时钟设置下做了标定,并与 Geyer 等人的频闪 LED 方法对比(Table 1):

像素时钟 标称行延迟 标定板方法,中位数(σ) LED 方法,中位数(σ)
12 MHz 137.5 µs 137.7 µs(0.56) 136.86 µs(3.12)
20 MHz 82.5 µs 82.55 µs(0.15) 83.54 µs(1.23)
32 MHz 51.56 µs 51.35 µs(0.19) 51.48 µs(1.70)
40 MHz 41.25 µs 41.14 µs(0.21) 41.09 µs(0.82)

两者都与标称值一致;标定板方法的重复性要紧密好几倍。对于 “typically have large exposure times”(意为:通常曝光时间较长)的手机,作者建议使用圆点图案,因为斑点检测比棋盘格角点更耐运动模糊。

在 Kalibr 中。wiki 把这个工具描述为提供 “full intrinsic calibration (projection, distortion and shutter parameters)”(意为:完整的内参标定(投影、畸变和快门参数)),模型有 pinhole-radtan-rs、pinhole-equi-rs 和 omni-radtan-rs,并有一个 --frame-rate 选项,用于 “Approximate framerate of the camera.”(意为:相机的近似帧率。)它的限制:“The codebase currently only supports a single camera, and cannot calibrate an IMU alongside it”(意为:代码库目前只支持单台相机,不能同时标定 IMU)(Kalibr wiki)。结果中的 line_delay 字段在 Kalibr 文件参考中有说明。

运动。只有图像跨行移动时,行延迟才是可观测的;静止的相机不提供关于它的任何信息。Oth 等人指出,对于沿扫描方向的快速运动,他们的误差模型可能变得退化,不过 “This does not occur in practice”(意为:这在实际中不会发生),他们把对最佳运动的完整研究留作 “for future research”(意为:未来的研究)。

  • 对照上限。line_delay × rows 必须小于该模式的帧周期。
  • 跨方法。来自文件或 API 的值与 LED 或标定板的测量值应该一致。不一致通常意味着模式、裁切或像素合并与所假定的不同。
  • 跨设置。在已知传感器时序随某项设置成比例变化的情况下,测得的延迟应该跟随它变化。Oth 等人把行延迟对像素时序做拟合,他们的标定板方法得到斜率 1650.02,标称值为 1650;LED 方法得到 1642.54(Table 2)。
  • 在图像中。校正之后,快速横摇时拍到的竖直直边应该是直的。

去畸变之后的逐像素时间。在原始图像上,像素的时间与它的行号成线性关系。大多数流程先对鱼眼图像去畸变,之后就不是这样了:“After image rectifiction, the linear relationship for each pixel respect to their row number will not hold”(意为:图像校正之后,每个像素与其行号之间的线性关系将不再成立)(Lv 等,2025)。他们的解决办法是一幅查找图像 ℛ(u),对每个校正后的像素给出它的原始行号占图像高度的比例,于是 t(u) = t(0) + ℛ(u) × 读出时间。他们把 Aria 的 2880 × 2880 RGB 图像校正为焦距 1200 px 的 2400 × 2400 针孔图像,并把这张映射图存为 8 位图像,“with 1 represent the first row, and 255 represent the last row in original image”(意为:1 代表原始图像的第一行,255 代表最后一行),原始视野之外的像素用 0。要用你对图像做的同一套去畸变来生成这张映射图。

每帧用多少个位姿。Lv 等人根据场景的运动来选择在读出期间采样的位姿数量:他们选取的时间步长是 “that ensures half of the reprojected pixels have fewer than 1 pixel reprojection error”(意为:能确保一半的重投影像素的重投影误差小于 1 个像素)的那一个,对 16 ms 的读出时间来说得到 “an average of eight motion samples within the readout time”(意为:读出时间内平均八个运动采样)。他们的结果见全局快门与卷帘快门。

运动物体。查找图给出的是静止点的时间。一个点如果在各行扫过时自己也在图像上移动,它被拍到的时间就会更早或更晚。Nazarenus 等人把延迟图和点在图像上的运动都线性化,得到 t = t(p₀) / (1 − ∇t · v),其中 ∇t 是每像素的延迟变化,v 是以像素每秒为单位的图像速度。对他们的相机(每行 2.85 µs,400 Hz),每帧最大 50 px 的图像运动给出 ∇t · v ≈ 5.5 × 10⁻²,小到可以直接使用 t(p₀)(Nazarenus 等,2026)。对一台类似 Aria 的 RGB 相机做同样的检查:

row time = 16 ms / 2880 rows ≈ 5.6 µs per row
point moving 500 px/s along the readout direction: ∇t·v = 5.6e-6 × 500 ≈ 0.003
point moving 2000 px/s: ∇t·v = 5.6e-6 × 2000 ≈ 0.011

这些图像速度是为举例而做的假设。即使是很快的图像运动,也只使拍摄时间改变约 1%,所以一阶修正的重要性不如首先知道 t(p₀)。

跟踪器。视觉惯性跟踪器使用行延迟的方式有两种:逐特征的位姿插值,或者中间行近似加一个随时间变化的相机–IMU 偏移;这些做法的比较见全局快门与卷帘快门,时间偏移方面见相机–IMU 时间偏移。

关闭防抖。设备端的电子防抖会对每一帧做变形,破坏图像行与读出时间之间的固定联系;任何用于几何的素材都要把它关掉(破坏标定的镜头效应)。

它修正不了什么。标定修正的是相机自身相对于静止场景的运动。手会自己动,而两台卷帘快门相机在不同的时刻看到同一个运动点;这就是上面那些多视角采集设备使用全局快门的原因(全局快门与卷帘快门)。

我用相机在最短曝光下拍摄,每帧一次短的 LED 闪光。曝光是 0.3 ms;
0.5、1.0 和 2.0 ms 的闪光在 30 fps、1080 行的画面中分别给出 H1、H2 和 H3 行高的亮条纹。
请由每一组数据计算行延迟,给出它们的均值和离散程度、读出时间,
并对照上限 line_delay <= 1 / (fps x rows) 做检查。然后写出以秒每行为单位的 Kalibr
line_delay 值。
请用 OpenCV 和 NumPy 写一个 Python 脚本,为鱼眼卷帘快门相机生成校正后的行号映射图 R(u):
给定原始鱼眼模型的 K 和 D、原始图像尺寸以及目标针孔模型的 K 和尺寸,
把每个校正后的像素映射回它的原始行,把 row / height 存为 float32
(原始图像之外为 -1),并另存为一幅 8 位图像,
第一行为 1,最后一行为 255,无效像素为 0。
我想用 kalibr_calibrate_rs_cameras 和一块 Aprilgrid 标定一台卷帘快门相机。
请给我 pinhole-equi-rs 模型的命令、一份录制检查清单(光照、曝光、
怎样运动才能让行延迟可观测、时长),以及如何对照帧率和行数
对得到的 line_delay 做合理性检查。