检测 SURF,SIFT,MSER特征

来源:互联网 发布:一路一带破产知乎 编辑:程序博客网 时间:2024/05/02 00:25
当尝试在不同图像之间匹配特征时,我们通常面临尺度变化的难题,即需要分析的图像在拍摄时与目标物体的距离是不同的,因此,目标物体在图像中有些不同的尺寸.为了解决这个问题,计算机视觉引人尺度不变的特征,主要的思想是每个检测到的特征点都伴随着对应的尺寸因子,即SURF特征。尺寸不变的特性,而且计算非常高效。特征点对应的圆圈的尺寸与图像尺寸的改变成正比。
// Read input image    cv::Mat image= cv::imread("church03.jpg",0);    std::vector<cv::KeyPoint> keypoints;//特征点的向量    // Construct the SURF feature detector object  构造SURF特征检测器    cv::SurfFeatureDetector surf(2500);  //阈值    // Detect the SURF features    surf.detect(image,keypoints);    cv::Mat featureImage;    //绘制这些特征      绘制特征点,加上尺寸与方向信息       使用DRAW_RICH_KEYPOINTS后关键点圆圈的尺寸与特征的尺寸成正比    cv::drawKeypoints(image,keypoints,featureImage,cv::Scalar(255,255,255),cv::DrawMatchesFlags::DRAW_RICH_KEYPOINTS);    // Display the corners    cv::namedWindow("SURF3 Features");    cv::imshow("SURF3 Features",featureImage);    //----------------------------------------------------------------------------------------------------    // Read input image    image= cv::imread("church01.jpg",0);    keypoints.clear();    // Construct the SURF feature detector object    cv::SiftFeatureDetector sift(        0.03,  // feature threshold        10.);  // threshold to reduce               // sensitivity to lines    // Detect the SURF features    sift.detect(image,keypoints);    cv::drawKeypoints(image,keypoints,featureImage,cv::Scalar(255,255,255),cv::DrawMatchesFlags::DRAW_RICH_KEYPOINTS);    // Display the corners    cv::namedWindow("SIFT Features");    cv::imshow("SIFT Features",featureImage);    //---------------------------------------------------    // Read input image    image= cv::imread("church01.jpg",0);    keypoints.clear();    cv::MserFeatureDetector mser;    mser.detect(image,keypoints);    // Draw the keypoints with scale and orientation information    cv::drawKeypoints(image,        // original image        keypoints,                  // vector of keypoints        featureImage,               // the resulting image        cv::Scalar(255,255,255),    // color of the points        cv::DrawMatchesFlags::DRAW_RICH_KEYPOINTS); //drawing flag    // Display the corners    cv::namedWindow("MSER Features");    cv::imshow("MSER Features",featureImage);    cv::waitKey();    return 0;

这里写图片描述

0 0
原创粉丝点击