I’m working on a project which is something like Bundler with my team, our aim is using different images of an object (we only have images, and know nothing about the positions these images took or parameters of cameras), to re-construct the 3-D module of the object. In this project, I used RANSAC on calculating homographies between two images, and eliminating bad feature pairs.

RANSAC is abbreviation of RANdom SAmple Consensus, in computer vision, we use it as a method to calculate homography between two images, and I’m going to talk about it briefly.

Here are two images, and for each image, I found 100 features.

I randomly chose colors to represent feature points, we can see, we can find comparison of most points between the two images, maybe this figure is more clear:

There are some mis-matched pairs in the above result, and for both panorama building and 3-D re-constructing, these pairs are bad pairs, and RANSAC method is exactly born for eliminating these points.

The RANSAC method is nothing but a loop:

- Select four feature pairs (at random)
- Compute homography H
- Compute inliers where ||pi’, H pi|| < ε (if not enough times, goto 1.)
- Keep largest set of inliers
- Re-compute least-squares H estimate using all of the inliers

About homography H:

Every time we randomly choose four pairs of points we build a matrix A, and the homography we want is just the null space of A.

In c++, I use armadillo to do matrix maths, so I can easily get null space of Matrix A by doing QR decomposition.

arma::mat Q, R; arma::mat ATranspose = A.t(); qr(Q,R,ATranspose); arma::mat x = randu<arma::mat>(9,1); for(int i=0; i<9; i++){ x(i,0) = Q(i,8); } for(int i=0; i<9; i++){ x(i,0) /= x(8,0); } double norm2= norm(x,2); arma::mat h = randu<mat>(3,3); h(0,0)=x(0,0)/norm2; h(0,1)=x(1,0)/norm2; h(0,2)=x(2,0)/norm2; h(1,0)=x(3,0)/norm2; h(1,1)=x(4,0)/norm2; h(1,2)=x(5,0)/norm2; h(2,0)=x(6,0)/norm2; h(2,1)=x(7,0)/norm2; h(2,2)=x(8,0)/norm2;

I used RANSAC method on the above images, and here are the left feature pairs (I’m now using same color circle to represent matching points in one pair):

Panorama building test using RANSAC:

1. The Great Wave of Kanagawa

2. Mountain

🙂

Pingback: 跟Hoevo缪庆学习VR/AR/MR的空间定位技术 | 硬创公开课 | Nokia 108()

Pingback: 硬创公开课|Hoevo CEO缪庆分享VR/AR/MR的空间定位技术 – 这就是AR()