进一步匹配(寻找源图与目标图像之间的透视变换)

bool refineMatchesWithHomography(const std::vector& queryKeypoints,const std::vector& trainKeypoints,  
float reprojectionThreshold,std::vector& matches,cv::Mat& homography)  
{  
    const int minNumberMatchesAllowed = 8;  
    if (matches.size() < minNumberMatchesAllowed)  
        return false;  
    // Prepare data for cv::findHomography    
    std::vector srcPoints(matches.size());  
    std::vector dstPoints(matches.size());  
    for (size_t i = 0; i < matches.size(); i++)  
    {  
        srcPoints[i] = trainKeypoints[matches[i].trainIdx].pt;  
        dstPoints[i] = queryKeypoints[matches[i].queryIdx].pt;  
        //srcPoints[i] = trainKeypoints[i].pt;  
        //dstPoints[i] = queryKeypoints[i].pt;  
    }  
    // Find homography matrix and get inliers mask    
    std::vector inliersMask(srcPoints.size());  
    homography = cv::findHomography(srcPoints,dstPoints,CV_FM_RANSAC,reprojectionThreshold,inliersMask);  
    std::vector inliers;  
    for (size_t i = 0; i minNumberMatchesAllowed;  
}  

参考:

Opencv图像识别从零到精通(23)----轮廓        

opencv3.1.0 特征点检测与图像匹配(features2d、xfeatures2d)

Opencv图像识别从零到精通(30)---重映射,仿射变换

你可能感兴趣的:(opencv,图像处理学习笔记,图像匹配,图像分析)