一、函数构造
// Draws matches of keypints from two images on output image.
void drawMatches( const Mat& img1, const vector<KeyPoint>& keypoints1,
const Mat& img2, const vector<KeyPoint>& keypoints2,
const vector<vector<DMatch> >& matches1to2, Mat& outImg,
const Scalar& matchColor=Scalar::all(-1), const Scalar& singlePointColor=Scalar::all(-1),
const vector<vector<char> >& matchesMask=vector<vector<char> >(), int flags=DrawMatchesFlags::DEFAULT );
二、参数详解
- img1 – 源图像1
- keypoints1 – 源图像1的特征点.
- img2 – 源图像2.
- keypoints2 – 源图像2的特征点
- matches1to2 – 源图像1的特征点匹配源图像2的特征点[matches[i]] .
- outImg – 输出图像具体由flags决定.
- matchColor – 匹配的颜色(特征点和连线),若matchColor==Scalar::all(-1),颜色随机.
- singlePointColor – 单个点的颜色,即未配对的特征点,若matchColor==Scalar::all(-1),颜色随机.
- matchesMask – Mask决定哪些点将被画出,若为空,则画出所有匹配点.
- flags – Fdefined by DrawMatchesFlags.
三、示例
☀ Demo1:
drawMatches(srcImg1, keyPoints1, srcImg2, keyPoints2, good_matches, result, Scalar(0, 255, 0), vector<char>(), 2);
效果:
☀ Demo2:
drawMatches(srcImg1, keyPoints1, srcImg2, keyPoints2, good_matches, result, Scalar(0, 255, 0), Scalar::all(-1));
效果:
☀ Demo3:
drawMatches(srcImg1, keyPoints1, srcImg2, keyPoints2, good_matches, result);
效果:
End && Enjoy!