Structure from motion (SfM) is a photogrammetric range imaging technique for estimating three-dimensional structures from two-dimensional image sequences that may be coupled with local motion signals.
The first step is to find matching features between the images.
1) Convert RGB images A and B to grayscale images A’ and B’
2) Detect SIFT(Scale Invariant Feature Transform) features A’ and B’
3) Find corresponding feature from A’ to B’ using its descriptor
Find essential matrix by findEssentialMat(). It internally uses 5-point algorithm to calculate the essential matrix from the matched features.
1) Randomly select sets of 5 matches (feature correspondence)
2) Generate E(Hypothesis) and evaluate using other points with pre-defined threshold – epipolar distance
3) Iterate 1)~2) for hypothesis candidates
4) Choose the most supportive hypothesis E having the most inliers
5) By applying overall procedure which is called RANSAC, we can effectively reject outliers
The pose from the essential matrix is recovered by recoverPose(). It returns a 3×3 rotation (R) and translation vector (t).
We would now like to reconstruct the geometry. Given two poses the 2D image points can then be triangulated using triangulatePoints().
$ pip install -r requirements.txt
$ python main.py --factor $FACTOR
$FACTOR: feature matching factor; the higher, the more outliers
While conducting visualization of 3D reconstruction several times, I adjusted feature matching factor. By sweeping the factor from 0.6 to 0.9 by 0.1, result shows that factor 0.7 satisfies both conditions best - 1) rejecting outliers well 2) shows recognizable reconstruction result
![]() |
---|
![]() |
FACTOR = 0.6 |
![]() |
---|
![]() |
FACTOR = 0.7 |
![]() |
---|
![]() |
FACTOR = 0.8 |
![]() |
---|
![]() |
FACTOR = 0.9 |
![]() |
front view |
---|---|
![]() |
side(left) view |
![]() |
top view |
Image(left) was taken on Iphone X. 3D Reconstruction(right) shows 3 separated objects quite well.
![]() |
feature matching |
---|---|
![]() |
reconstructed |