Search code examples
opencvimage-processingcomputer-visionfeature-detection

OpenCV: Drawing matches in top and bottom configuration?


I am trying to use drawmatches function in OpenCV.

It put the image in left and right format. I want the images to be put in top-down format and then draw the matches for more clarity.

Is there a way in which it can be done in OpenCV? Or, I will have to write a new function?


Solution

  • I am afraid you have to write your own function. I think it should not be too complicated.

    As a starting point just have a look at https://github.com/Itseez/opencv/blob/2.4/modules/features2d/src/draw.cpp where we have the function _prepareImgAndDrawKeypoints

    static void _prepareImgAndDrawKeypoints( const Mat& img1, const vector<KeyPoint>& keypoints1,
                                             const Mat& img2, const vector<KeyPoint>& keypoints2,
                                             Mat& outImg, Mat& outImg1, Mat& outImg2,
                                             const Scalar& singlePointColor, int flags )
    {
        Size size( img1.cols + img2.cols, MAX(img1.rows, img2.rows) );
    

    for example size should be changed to

    Size size( MAX(img1.cols + img2.cols), img1.rows + img2.rows );
    

    and then you can continue to study that function (and the other ones) and complete your task. Maybe you can also contribute to OpenCV too with your new feature.