The aim of the project is to find homography between two image scenes using DLT along with RANSAC. Everything has been coded from scratch. The 'Collage Image' folder contains a collage of book images (skewed, rotated, translated, distorted) and some of the raw book images are present in 'Test Images' folder. The aim is to find homography between the test images and the collage image and given a test image, find its bounding box in the collage image.
Note: The code can be easily modified to find homography between any two image scenes.
Following is the process implemented to find the bounding box of a test image in the collage image:
- Given a test image and the collage image
- Find SIFT features in both test and collage image
- Find the feature matches using any matcher (used BF matcher in this project)
- Pick any four random pairs of matches and normalise them (to have their centroid at (0,0) and average distance from the origin is sqrt(2))
- Find homography using the above points using DLT
- Find the reprojection error using the homography calculated and store all the inliers (inliers are those points whose reprojection error is below the threshold decided)
- Repeat steps 4-6 for N iterations (used 4000 in the results, though 1000 is good enough too)
- Store the maximum no. of inliers in the N iterations
- Again normalise the inlier points in the above step
- Find homography in the above using DLT in least-squared sense
- Apply the homography obtained above on the corner points of the test image to get their corresponding positions in the collage image
- Draw lines between the mapped corners to get the bounding box of the test image in the collage
Green: Inlier matches
Red: Outlier matches
Green: Inlier matches
Red: Outlier matches