how to find overlapping region between images in opencv?

c, computer-vision, image-processing, opencv

Solution

First of all, have you seen a new "stitching" module introduced in OpenCV 2.3?

It provides a set of building blocks for stitching pipeline including blending and "finding an overlap" (e.g. registration) steps. Here is a documentation: http://docs.opencv.org/modules/stitching/doc/stitching.html and an example of stitching application: stitching_detailed.cpp

I recommend you to study the code of this sample for better understanding of the details.

Regarding the finding of overlap there are several common approaches in computer vision:

- optical flow

- template matching

- feature matching

For your case I recommend the last one - it works very well on the photos. And this approach is already implemented in OpenCV - explore the OpenCv source and see how the `cv::detail::BestOf2NearestMatcher` works.

Problem

I am trying to implement alpha blending with two images for image stitching . My first image is this -> here is my second image -> here is my result image -> As you can see the result is not proper.I think I first have to find the overlapping region between then and then implement alpha blending on the overlapping part.

Original source