ORB-SLAM proposes an automatic initialization procedure that selects Homography or Fundamental models according to the scene and delays initialization when quality is inadequate. This is a working note on its details.
1. Initialization flow
Step 0. Select a reference frame and extract ORB features
The reference frame needs more than 100 extracted ORB features.
Step 1. Match current-frame and reference-frame ORB features
The current frame also needs more than 100 features; otherwise return to Step 0.
Use the DBoW2 bag of words to accelerate matching.
If fewer than 100 matches are found, return to Step 0.
Otherwise initialize.
Step 2. Estimate Homography and Fundamental models concurrently
For Homography,
xc=Hcrxr.(1)
RANSAC uses four correspondences per hypothesis.
For Fundamental matrix,
xcTFxr=0.(2)
RANSAC uses eight correspondences per hypothesis.
The RANSAC iteration count is fixed. In every iteration, both models receive a score:
M is H or F. TM comes from a 95% chi-squared test: TH=5.99 for two degrees of freedom and TF=3.84 for one degree of freedom, assuming one-pixel standard deviation. The original ORB-SLAM implementation sets Γ=TH.
After all iterations, retain the highest-scoring H and F.
Step 3. Select Homography or Fundamental
RH=SH+SFSH.(4)
Use Homography if RH>0.45; otherwise use Fundamental.
Steps 4–5. Recover pose, map points, and run BA
Recover relative pose and 3D map points from the selected model, then run bundle adjustment.
The main technical questions are how to estimate H and F, and how to decompose each into rotation R and translation t.
2. Homography matrix
In the first camera frame, a 3D point is P=[X,Y,Z]T. If the points lie on a plane,
nTP+d=0,−dnTP=1.(5–6)
Projecting P into the second frame yields
s2p2=K(RP+t)=K(R−dtnT)P=K(R−dtnT)s1K−1p1.
Since image points are homogeneous, H is defined up to scale:
Set h33=1, giving eight unknowns. Each correspondence gives two equations; four correspondences solve H. With more matches, solve the overdetermined system
Mx=b
by least squares, for example
x=(MTM)−1MTborx=R−1QTb
from QR decomposition.
Solution 2
Keep all nine parameters and solve
Mx=0.
The solution is x=ηξ, another up-to-scale form. ξ is the right singular vector associated with the smallest singular value of M, or the eigenvector of MTM with its smallest eigenvalue. ORB-SLAM uses this form and estimates Homography from eight matches during RANSAC to remain consistent with Fundamental estimation.
ORB-SLAM also normalizes 2D features to zero mean and unit variance before Homography computation, improving numerical conditioning.
3. Fundamental matrix
For the same 3D point observed by two cameras,
s1p1=KP,s2p2=K(RP+t).(11)
Define normalized coordinates xi=K−1pi. Then
s2x2=s1Rx1+t.(12)
Crossing with t gives the epipolar constraint
x2TE[t]×Rx1=0,(13)
where E is the essential matrix. Reintroducing pixel coordinates gives
p2TF=K−TEK−1K−T[t]×RK−1p1=0.(14)
F is up to scale and hence has eight degrees of freedom. One correspondence contributes one equation, so eight pairs solve it. Expanding Equation (14) is linear in the nine elements of F; solve Mx=0 with the same SVD approach as Homography.
4. Scoring models
For Homography, use squared Mahalanobis distance between corresponding points:
x2′=Hx1,d2=(x2−x2′)TΣ−1(x2−x2′).
This follows a two-degree-of-freedom chi-squared distribution, so Equation (3) uses Γ=TH=5.99.
For Fundamental matrix, use squared point-to-epipolar-line distance. The line in camera 2 is
x2TnFx1=0,
and the squared distance is
d2=(Fx1)12+(Fx1)22(x2TFx1)2.
Under unit-pixel Gaussian noise it follows one-degree-of-freedom chi-squared, hence TF=3.84. TM separates inliers from outliers.
5. Decompose Fundamental matrix into rotation and translation
Choose by triangulation: points must lie in front of both cameras, have low reprojection error, sufficient parallax, and yield a clearly unique best candidate. If multiple candidates remain equally good, reject this initialization attempt.
6. Recover pose from Homography
ORB-SLAM produces eight Homography pose candidates, then selects one using triangulated-point count and parallax. It accepts only when:
the best count is more than 0.7 times the runner-up count;