NOTE / 3/7/2019
[ORB-SLAM2] Chi-Squared Outlier Rejection
Outliers seriously affect SLAM accuracy and must be rejected. A common approach calculates an error and classifies a match as an outlier when that error exceeds a selected threshold. The questions are how to calculate the error and how to choose the threshold.
Error
For feature-based visual SLAM, the usual measure is reprojection error. Let be the 2D feature location and the 2D location obtained by projecting a map point into the image. The reprojection error is
It follows a Gaussian distribution:
Covariance is commonly determined by the pyramid level at which the feature was extracted. Let be the per-level image-pyramid scale factor when extracting ORB features ( in ORB-SLAM), and let the standard deviation at level zero be pixels ( pixel in ORB-SLAM). Then the reprojection-error covariance of a feature extracted at pyramid level is
The error in (1) is a 2D vector, so a threshold is not directly convenient. Convert it to a scalar by taking an inner product. A single unweighted threshold across pyramid levels would be inappropriate, so use the covariance to weight the residual:
Covariance weighting normalizes the residual. Equation (4) can be rewritten as
Moreover,
This is a multivariate standard normal distribution. Thus reprojection errors from all pyramid levels are normalized, or whitened, and one threshold is sufficient. Note that .
Threshold
Equation (5) is the sum of squares of two independent standard-normal random variables. It follows a chi-squared distribution with two degrees of freedom. Wikipedia describes the chi-squared distribution as:
In probability theory and statistics, the chi-squared distribution with degrees of freedom is the distribution of a sum of the squares of independent standard normal random variables.
The degrees of freedom equal the vector dimension. Probability density functions and cumulative distributions for several degrees of freedom are shown below.


Let the cumulative distribution function be . Given , the interval is determined. Treat inside this interval as an inlier and outside it as an outlier. Thus is the threshold :
A common choice is , so an inlier has only a 5% probability of being wrongly classified as an outlier. Tables of values are available:

ORB-SLAM2 uses . Monocular projection has two degrees of freedom and threshold ; stereo projection has three degrees of freedom and threshold .


References
- Hartley R, Zisserman A. Multiple View Geometry in Computer Vision. 2003.
- Wikipedia: Chi-squared distribution
More SLAM articles
- ORB feature-extraction strategy and its impact on ORB-SLAM2
- ArUco EKF SLAM
- Particle filter / Monte Carlo localization
Related code