SLAM中的卡方分布

MKT-porter / 2024-09-23 / 原文

 

 

 

 

实际代码

// openvslam/module/two_view_triangulator.cc:95
// chi-squared values for p=5%
// (n=2)
constexpr float chi_sq_2D = 5.99146;
// (n=3)
constexpr float chi_sq_3D = 7.81473;

Vec2_t reproj_in_cur;
float x_right_in_cur;

camera->reproject_to_image(rot_cw, trans_cw, pos_w, reproj_in_cur, x_right_in_cur);

if (is_stereo) {
    const Vec2_t reproj_err = reproj_in_cur - keypt;
    const auto reproj_err_x_right = x_right_in_cur - x_right;
    if ((chi_sq_3D * sigma_sq) < (reproj_err.squaredNorm() + reproj_err_x_right * reproj_err_x_right)) {
        return false;
    }
}
else {
    const Vec2_t reproj_err = reproj_in_cur - keypt;
    if ((chi_sq_2D * sigma_sq) < reproj_err.squaredNorm()) {
        return false;
    }
}