This my attempt at using the GPU to calculate the homography between an image using RANSAC. Each RANSAC iteration is done in parallel. The random number generation used by RANSAC was done the CPU and uploaded the GPU. You might also find the following useful in this code:
- Example of using OpenCV’s GPU SURF code for detecting and matching
- SVD implemented as a CUDA kernel function, with parameters to specify the matrix size
In regards to the SVD function, I ported a version of GNU Scientific Library Jacobi SVD.
Last update: 7th July 2012
This code requires OpenCV 2.x installed and CUDA development libraries. The code is targeted at Linux but should be easy to compile in Windows.
Use CodeBlocks to open the project and compile. CUDA is assumed to be installed at /usr/local/cuda.
CUDA_RANSAC_Homography accepts 3 parameters:
./bin/Release/CUDA_RANSAC_Homography [img.jpg] [target.jpg] [results.png]
The first two are the input images and the third is the output of the matched features. Some sample images are included in the sample directory.
There are also two #define options in CUDA_RANSAC_Homography.h
NORMALISE_INPUT_POINTS normalises the point before calculating the Homography. In theory, it should provided better stability. Try with and without and see what you get.
BIAS_RANDOM_SELECTION uses my variant of RANSAC that uses a bias random number generation, than than uniform like the vanilla implementation. The bias random number is based on the score of the matched feature pairs. Features with better scoring matches will tend to get picked more often than those with lower scores. This option is useful when the number of iterations is low for the given inliers/outlier ratio.
I’m releasing my part under the Simplified BSD license, but the CUDA SVD kernel code is GPL (whatever version GSL is under).