跳转到内容

C401 第 1 课:从可穿戴素材得到相机位姿

在单帧上运行的手部检测器,测到的是手相对于镜头的位置,而镜头随佩戴者的头一起运动。要让它变成机器人可以学习的轨迹,处理流程必须先减去头部的运动,为此它需要相机在每个时间戳的位姿。本课讲解处理流程怎样从头戴素材得到这个位姿,以及怎样判断它对不对。完整的讲解见 SLAM 与 VIO 基础和在可穿戴素材上运行 SLAM。

这些术语也都在术语表的 SLAM 部分中。

术语 含义
六自由度位姿(6-DoF pose) 相机(或 IMU 机体)在固定世界坐标系中的 3D 位置加 3D 朝向
视觉里程计(VO) 只靠图像逐帧估计运动,没有可重复使用的地图;误差会累积
视觉惯性里程计(VIO) 把图像与 IMU(陀螺仪和加速度计)融合的里程计
SLAM 同时定位与建图:里程计加上一张估计器能够识别并重复使用的地图,所以再次看到某个地方时漂移会被修正
光束法平差(BA) 联合细化相机位姿和 3D 点的优化,使重投影的点与它们的检测结果相符
回环闭合(Loop closure) 识别出一个重访的地方,并把累积的漂移从轨迹中拉回去
因果与离线(Causal vs offline) 因果估计只使用过去和当前的测量值;离线估计可以使用整段录制
ATE / RPE 绝对轨迹误差(把整条轨迹对齐一次之后的位置均方根误差)和相对位姿误差(在固定间隔内运动的误差)

RoboCap 的作者把利害关系说得很直白:“The quality of egocentric data is bounded by the accuracy of its 3D labels, namely the human hand and head poses”(意为:第一人称数据的质量受限于其 3D 标签的精度,即人的手部位姿和头部位姿)(RoboCap, 2026)。位姿还根据 IMU 的重力估计给轨迹一个一致的“上”方向,让几台设备在对着同一张地图定位时处于同一个坐标系,并且是 3D 重建的输入(SLAM 与 VIO 基础)。

ORB-SLAM3 的作者说明了其中的区别:“In contrast, VO systems put their focus on computing the agent’s ego-motion, not on building a map”(意为:相比之下,VO 系统把重点放在计算智能体的自身运动上,而不是建立地图)(Campos et al., 2020)。加上 IMU 会改变哪些量可能漂移。重力是一个绝对的竖直参考,所以横滚和俯仰不再漂移;位置和偏航(绕重力方向的旋转)仍然漂移,而限制它们的是回环闭合(SLAM 与 VIO 基础)。

The parts of a visual-inertial SLAM system A block diagram. Camera frames go to the front-end, which detects and tracks features or, in direct methods, compares pixel intensities. IMU samples are preintegrated between frames. Both feed the back-end, which is either a filter such as the MSCKF or a sliding-window bundle adjustment, and which outputs a pose for every frame plus a local map. Visual or visual-inertial odometry stops there and drifts. SLAM adds a loop-closure stage, drawn as a dashed return path: place recognition notices a revisited place, and a pose graph or global bundle adjustment corrects the accumulated drift. Without loop closure, odometry drift keeps growing; with an IMU, gravity fixes roll and pitch, so the drift is in position and yaw. Calibration (intrinsics, extrinsics and camera-IMU time offset) is an input to every stage. Camera frames IMU samples Front-end track features, or compare pixels Preintegration IMU motion between camera frames Back-end filter (MSCKF) or sliding-window bundle adjustment Pose every frame, + local map Loop closure (SLAM only) recognise a revisited place, correct drift Calibration feeds every stage: intrinsics, extrinsics, time offset Without it (VO, VIO) drift grows; with an IMU,in position and yaw
The parts of a visual-inertial SLAM system. The front-end tracks features (or compares pixels, in direct methods), the IMU is preintegrated between frames, and the back-end, a filter or a sliding-window bundle adjustment, turns both into a pose for every frame. Odometry stops there and drifts; SLAM adds loop closure to correct that drift when a place is seen again. Calibration is an input to every stage.

每个估计器内部都有一个前端(front-end),它把图像变成测量值(被追踪的特征,或直接法中的像素强度),还有一个后端(back-end),要么是 OpenVINS 这样的滤波器,要么是 Basalt 或 ORB-SLAM3 的局部建图这样的滑动窗口光束法平差。两种后端都把标定当作已知量。如果第二台相机的外参是错的,它就帮不上忙:“Stereo cameras with an IMU didn’t always perform best, because it requires more accurate calibration than the case of a monocular camera with an IMU”(意为:带 IMU 的双目相机并不总是表现最好,因为它比带 IMU 的单目相机需要更精确的标定)(VINS-Fusion,引自 SLAM 与 VIO 基础)。

公制尺度(metric scale)指距离以真实的米为单位给出。已标定的双目对在第一帧就通过三角化给出公制深度。只有一台相机时,视觉只能恢复相差一个未知比例因子的运动,必须由 IMU 提供这个比例因子,而 IMU 只有在设备加速时才能做到(SLAM 与 VIO 基础)。

为什么一台相机看不出尺度:针孔相机只记录方向,即比值 X/Z 和 Y/Z。把整个场景和相机的每一步移动都按同一个因子缩放,图像不会改变,所以一个两倍大的房间、用两倍长的步子走过,看起来完全一样。双目基线是一个以米为单位的已知长度,加速度计报告的是米每二次方秒;两者中的任何一个都能确定这个因子。在匀速运动时,加速度计没有可供比较的运动,这就是 IMU 需要加速度的原因。

工作中的头部大多在转动。MEgoVista 的作者写道:“Head-worn capture is rotation-dominated, so translation over a keyframe interval is often negligible”(意为:头戴采集以旋转为主,所以一个关键帧间隔内的平移往往可以忽略)(MEgoVista)。纯旋转不给单台相机任何视差(parallax),所以深度和尺度都无法从图像中恢复。

Why pure head rotation gives a single camera no depth Three top-down panels with a point P in front of the camera. Left, the head translates: the camera sees P from two different centres, the two rays cross at P, and the angle between them, the parallax, lets the point be triangulated. Middle, the head only rotates: the camera centre stays in the same place, so both views' rays to P lie along the same line; there is no parallax, and depth and scale cannot be recovered from the images. Right, a stereo pair: two camera centres a fixed baseline apart see P in every frame, so there is parallax without any head motion and the depth is metric. P P P Head translates Head only rotates Stereo pair rays cross: parallax,P can be triangulated same centre, same ray:no parallax, no depth baseline in every frame:metric depth without moving parallax baseline
Why rotation-dominated head motion starves a single camera of depth. Translation gives two viewpoints whose rays cross at the point (parallax); pure rotation about the camera centre gives the same ray twice, so neither depth nor scale can be recovered from the images. A stereo pair has a baseline in every frame. Standard multi-view geometry; schematic.

在头戴素材上哪些地方会出问题,以及已发表的解决办法

Section titled “在头戴素材上哪些地方会出问题,以及已发表的解决办法”
失效 出了什么问题 已发表的解决办法 来源
快速旋转、模糊 特征轨迹中断;追踪器漂移或发散 一个估计器中使用更多相机;为图像块追踪器做降采样;离线细化 RoboCap
以旋转为主的运动 单目惯性的尺度收敛慢或出错 用双目给出公制初值;之后由 IMU 提供重力 MEgoVista
单目启动不稳 每个片段开头丢帧 用保存下来的工作区地图做初始化 UMI
视野中的手和物体 运动的像素把相机估计带偏 在图像中和置信度权重中使用手部掩码 HaWoR
标定漂移 双目深度错误,位姿有偏差 在线标定 RoboCap

这张表浓缩了实用指南的失效模式表,那里列出的更多。手那一行的原因很简单:SLAM 假设它追踪的东西是静止的,而在第一人称操作中,手和手持物体独立于头部运动,并且可能占据视野的很大一部分。它们上面的特征会把估计拉向它们的运动,所以处理流程把它们用掩码去掉,只用背景像素估计相机(视野中的手和手持物体)。其中两行的数字值得记住。RoboCap 报告说,在 150 顶已部署的帽子上,“factory calibration leaves a median front-pair epipolar residual of 3.8 px, which online calibration reduces to 0.56 px”(意为:出厂标定留下的前向双目对极线残差中位数为 3.8 px,在线标定把它降到 0.56 px)。另外,保留鱼眼镜头模型而不做校正,可以保住图像的周边区域,当手遮住图像中心时这部分仍然可见(在可穿戴素材上运行 SLAM)。

实时追踪器只能使用过去的数据。离线系统可以在知道每一次重访之后,对整段录制运行光束法平差。在 RoboCap 上,“the causal estimate available during capture is about twice as inaccurate as the offline trajectory”(意为:采集过程中可用的因果估计,其误差大约是离线轨迹的两倍)(RoboCap)。因此训练标签通常是离线生成的(SLAM 与 VIO 基础)。

当前的公开头戴采集设备大多描述的是用已发表的组件搭建的自有处理流程,而不是一个未经修改的软件包(SLAM 与 VIO 系统对比)。对一个刚起步的团队,各开源系统在四项约束条件上有所不同:

约束条件 实用指南的表格显示什么
许可协议 ORB-SLAM3、VINS-Mono、VINS-Fusion、OpenVINS、DSO 和 DM-VIO 是 GPL-3.0;Basalt、Kimera、DROID-SLAM 和 DPVO 是宽松许可;MASt3R-SLAM 是非商业性的
镜头 不做校正的鱼眼:ORB-SLAM3、VINS-Mono/Fusion、OpenVINS、Basalt;DSO、DM-VIO 和基于学习的追踪器要求针孔图像或去畸变后的图像
会漂移的标定 OpenVINS 在线估计内参、外参和时间偏移;VINS-Mono/Fusion 可以估计外参和时间偏移;其他系统把标定作为输入
没有 IMU,一台相机 只有纯视觉系统适用(DSO、DROID-SLAM、DPVO/DPV-SLAM、MASt3R-SLAM),并且全都相差一个未知尺度

来源:SLAM 与 VIO 系统对比,按约束条件选择。用多少台相机、把它们指向哪里,取决于团队自己的模型需要什么;实用指南不推荐任何布局。

Absolute trajectory error and relative pose error The same estimated trajectory, which slowly drifts away from the reference, scored two ways. Left, absolute trajectory error (ATE): the estimate is aligned to the reference once, and the error is the root mean square of the distances between matching poses; because drift accumulates, those distances grow along the path, so ATE measures global drift. Right, relative pose error (RPE): the motion over each fixed interval, for example 1 second as in TUM VI, is compared with the reference motion over the same interval, drawn as a dashed arrow from the same starting point; each segment's error stays small even while the whole path drifts, so RPE measures local accuracy. ATE: absolute trajectory error align once, RMS of pose distances errors grow along the path: measures global drift RPE: relative pose error compare motion over each interval each segment's error stays small: measures local accuracy reference estimate error reference motion over the interval
Two ways to score the same drifting trajectory. ATE aligns the whole estimate to the reference once and takes the RMS of the remaining distances, so it grows with accumulated drift. RPE compares the motion over each fixed interval (TUM VI uses 1-second segments), so it stays small while the path drifts and measures local accuracy instead. Schematic.

ATE 衡量一个 episode 内的全局漂移;RPE 衡量局部精度,这正是短时域策略所看到的。已发表的数值只在同一篇论文的同一张表内才可比,即同一种对齐方式、同一组序列(SLAM 与 VIO 系统对比)。参考必须比追踪器更好:Shu et al. 要求 “the GT error should be smaller than that of SLAM by at least half an order of magnitude”(意为:真值的误差应当比 SLAM 的误差至少小半个数量级)(Shu et al., 2025;见参考必须有多准)。原因是,测得的误差既包含追踪器的误差,也包含参考的误差;如果这两个误差相互独立,并且参考大约好三倍,那么测得的数值与追踪器自身误差相差在约 5% 以内。没有动作捕捉时,重访标记点可以在少数几个点上测量漂移:MobileEgo Anywhere 在每次录制开始时放一个 ArUco 标记,并在佩戴者回到它那里时测量漂移(现场抽查)。

  1. 一位同事认为有了 VIO 就不需要回环闭合。没有回环闭合时,位姿的哪些部分仍然漂移?
  2. 你的采集设备有一台鱼眼相机和一个 IMU,大多数片段的头几秒没有位姿。可能的原因是什么,UMI 对此做了什么?
  3. 你的产品将以闭源方式发布。ORB-SLAM3、OpenVINS 和 Basalt 中,哪一个是宽松许可?
  4. 为什么用离线轨迹而不是实时轨迹来生成训练标签?
  5. 你在录制的住家里没有动作捕捉。怎样仍然能测量漂移?
  1. 位置和偏航。重力使横滚和俯仰可观测;限制其余部分的是回环闭合。
  2. 单目惯性初始化需要平移和加速度,而以旋转为主的头部或手部运动提供得很少。UMI 先录制一小段建图过程,然后每次示范都从这张保存下来的地图开始。
  3. Basalt(BSD-3-Clause)。ORB-SLAM3 和 OpenVINS 是 GPL-3.0。
  4. 离线光束法平差可以利用这次录制中的每一次重访;RoboCap 的因果估计,误差大约是它的离线轨迹的两倍。
  5. 在开始处放一个标记,每次佩戴者回到它那里时测量漂移,像 MobileEgo Anywhere 那样做。它测量的是少数几个点上的漂移,而不是整条轨迹上的漂移。