I am detecting and matching features of a pair of images, using a typical detector-descriptor-matcher combination and then findHomography
to produce a transformation matrix.
After this, I want the two images to be overlapped (the second one (imgTrain
) over the first one (imgQuery
), so I warp the second image using the transformation matrix using:
cv::Mat imgQuery, imgTrain;
...
TRANSFORMATION_MATRIX = cv::findHomography(...)
...
cv::Mat imgTrainWarped;
cv::warpPerspective(imgTrain, imgTrainWarped, TRANSFORMATION_MATRIX, imgTrain.size());
From here on, I don't know how to produce an image that contains the original imgQuery
with the warped imgTrainWarped
on it.
I consider two scenarios:
1) One where the size of the final image is the size of imgQuery
2) One where the size of the final image is big enough to accommodate both imgQuery
and imgTrainWarped
, since they overlap only partially, not completely. I understand this second case might have black/blank space somewhere around the images.