This repository is an implementation of image stitching algorithm using the opencv contrib version which contains some additional implemented algorithms by the opencv devs. Those algorithms are not included in the basic version of opencv.
First, it needs the opencv contrib library installed in the pc(it will be linked below, so just download it). Then the IDE need to be set so the linker knows those external references made in the library.
IMPORTANT: make sure the solution platform is set to x64 architecture, as the opencv is build on x64, otherwise the solution won't build.
In Visual Studio there are 3 settings to be made in the project settings:
The algorithm's goal is to receive two images with a "common" area and to stitch those two images into a single one. It may be easier for the human eye to recognise this matching, but stitching two images with this algorithm attracts a constraint: the user need to input the images in order, as the left image first and the right image second. This order confirms that there is a common zone, known by the user, but also there can be inputed two images with no common area and still representing a sequence. In this case the algorithm doesn't work.
There are some steps followed in order to implement the stitching algorithm:
This SURF method used to detect the KeyPoints is a popular method implemented in the opencv library. It detects the keypoints based on a hessian threshold. To get more keypoints in a image, you need to lower the threshold.
For more information about SURF go to opencv documentation.
Using the same SURF method, the descriptors are computed and extracted based on the previous KeyPoints detected.
FLANN(Fast Library for Approximate Nearest Neighbors) finds the best matches for local image features. Those matches are calculated based on the descriptors of the images. After getting those matches, there needs to be a filter applied on them: the distance of the matches needs to be 3 times the min_dist.
For more information about the FLANN matching method visit OpenCV: Feature Matching with FLANN.
RANdom SAmple Consensus (RANSAC) is a general parameter estimation approach designed to cope with a large proportion of outliers in the input data. Basically RANSAC approximates based on the most "good" input values, the ones "odd" are removed from the aproximation.
Using the RANSAC method for approximation, we find the homography matrix, a 3x3 mask. The homography's goal is to rotate an given image to match another image viewed from another perspective.
The algorithm works only if the user inputs two images matching the description: the two images represents a sequence, so it has a common area and those images are inputed correctly, the first image need to be the one leftmost and the second image needs to be the rightmost. If this description is not matched, then the result is not the one desired.