概念
Bundle Adjustment,中文名称是光束法平差,经典的BA目的是优化相机的pose和landmark,其在SfM和SLAM 领域中扮演者重要角色。开发Ceres的主要原因之一是需要解决大规模的Bundle Adjustment. 目前bundle adjustment 优化框架最为代表的是ceres solver和g2o ,据说ceres的命名是天文学家Piazzi闲暇无事的时候观测一颗没有观测到的星星,最后用least squares算出了这个小行星的轨道,故将这个小行星命名为ceres。
Bundle Adjustment 定义
Bundle Adjustment的目标是找到使重投影误差最小的3D点位置和相机参数。这个优化问题通常被描述为非线性最小二乘法问题,要最小化的目标函数即为测得图像中特征点位置和相机成像平面上的对应的投影之间的差的平方。ceres例程使用了BAL数据集:Bundle Adjustment in the Large .ceres 例程是examples文件夹中的 simple_bundle_adjuster.cc 。
观察值:像素点坐标
优化变量:相机pose 、相机内参、lanemark概念概念
ceres 代码解读
// Templated pinhole camera model for used with Ceres. The camera is
// parameterized using 9 parameters: 3 for rotation, 3 for translation, 1 for
// focal length and 2 for radial distortion. The principal point is not modeled
// (i.e. it is assumed be located at the image center).
struct SnavelyReprojectionError {
SnavelyReprojectionError(double observed_x, double observed_y)
: observed_x(observed_x), observed_y(observed_y) {}
template <typename T>
bool operator()(const T* const camera,
const T* const point,
T* residuals) const {
// camera[0,1,2] are the angle-axis rotation.
T p[3];
ceres::AngleAxisRotatePoint(camera, point, p);
// camera[3,4,5] are the translation.
p[0] += camera[3];
p[1] += camera[4];
p[2] += camera[5];
// Compute the center of distortion. The sign change comes from
// the camera model that Noah Snavely's Bundler assumes, whereby
// the camera coordinate system has a negative z axis.
T xp = -p[0] / p[2];
T yp = -p[1] / p[2];
// Apply second and fourth order radial distortion.
// k1 k2