检测 SURF,SIFT,MSER特征

当尝试在不同图像之间匹配特征时,我们通常面临尺度变化的难题,即需要分析的图像在拍摄时与目标物体的距离是不同的,因此,目标物体在图像中有些不同的尺寸.为了解决这个问题,计算机视觉引人尺度不变的特征,主要的思想是每个检测到的特征点都伴随着对应的尺寸因子,即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;

这里写图片描述

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值