【svopro】feature_alignment代码梳理

1. align2D

processFrame主流程==> sparseImageAlignment ==>void StereoTriangulation::compute > Matcher::MatchResult res = matcher.findEpipolarMatchDirect =>MatchResult res = findLocalMatch>res = feature_alignment_utils::align2D

bool align2D(const cv::Mat& cur_img, uint8_t* ref_patch_with_border, uint8_t* ref_patch,
    const int n_iter, const bool affine_est_offset, const bool affine_est_gain,
    Keypoint& cur_px_estimate, bool no_simd, std::vector<Eigen::Vector2f>* each_step) 

程序功能: 实现2D对齐
通过相邻两帧图像的特征匹配,来估计相机的运动,并将当前帧图像以相对精确的方式对齐到前一帧图像。

输入:当前帧图像(cur_img)、参考图像(ref_patch_with_border)、不带边界的参考图像(ref_patch)、迭代次数(n_iter)、是否使用仿射偏移(affine_est_offset)、是否使用仿射缩放(affine_est_gain)、当前像素位置的估计值(cur_px_estimate)、是否禁止使用SIMD优化(no_simd)、每次优化步骤的输出向量指针(each_step)。

输出:是否收敛(converged)。

算法步骤:

  1. 通过参考图像计算梯度和海森矩阵,计算梯度的方法是通过求解(x, y)位置处像素值沿x和y方向的梯度。同时可以进行仿射变换的偏移和缩放优化。

  2. 初始化变量,包括patch大小、面积、以及各种优化参数等。

  3. 根据当前像素位置的估计值,计算并存储每次优化迭代的步骤。

  4. 根据当前像素位置的估计值、参考图像、梯度和海森矩阵等信息,通过插值方法计算搜索的patch,并比较当前patch和参考patch的误差(包括仿射变换的误差),得到更新公式。

  5. 随着迭代次数的不断增加,对当前像素位置的估计值进行不断更新,直到满足收敛条件后结束。最终输出当前是否收敛的结果。

猜你喜欢

转载自blog.csdn.net/Darlingqiang/article/details/131214212