opencv3/C++ 實(shí)現(xiàn)SURF特征檢測
SURF即Speeded Up Robust Features加速魯棒特征;
SURF可以用于對象定位和識別、人臉識別、3D重建、對象跟蹤和提取興趣點(diǎn)等。
工作原理:
1、選擇圖像中POI(Points of Interest) Hessian Matrix;
2、在不同的尺度空間發(fā)現(xiàn)關(guān)鍵點(diǎn),非最大信號壓制;
3、發(fā)現(xiàn)特征點(diǎn)方法、旋轉(zhuǎn)不變性要求;
4、生成特征向量;

類SURF中成員函數(shù)create()參數(shù)說明:
static Ptr<SURF> create( double hessianThreshold=100,//SURF中使用的hessian關(guān)鍵點(diǎn)檢測器的閾值 int nOctaves = 4, //關(guān)鍵點(diǎn)檢測器將使用的金字塔組數(shù)量 int nOctaveLayers = 3,//高斯金字塔每個組內(nèi)圖像的層數(shù) bool extended = false, //擴(kuò)展描述符標(biāo)志(true使用擴(kuò)展的128個元素的描述符,false使用64個元素的描述符) bool upright = false//旋轉(zhuǎn)的特征標(biāo)志(true不計(jì)算方向,false計(jì)算方向) );
函數(shù)detect()用來檢測圖像或圖像集中的關(guān)鍵點(diǎn)。
基類Feature2D中成員函數(shù)detect()參數(shù)說明:
void detect( InputArray image,//圖像 CV_OUT std::vector<KeyPoint>& keypoints,//檢測到的關(guān)鍵點(diǎn),(在圖像集中關(guān)鍵點(diǎn)[i]是在圖像[i]中檢測到的一組關(guān)鍵點(diǎn)) InputArray mask=noArray() //指定在哪里尋找關(guān)鍵點(diǎn)的掩碼(必須是在感興趣區(qū)域中具有非零值的8位整數(shù)矩陣) );
函數(shù)drawKeypoints()的參數(shù)說明:
void drawKeypoints( InputArray image, //源圖像 const std::vector<KeyPoint>& keypoints, //來自源圖像的關(guān)鍵點(diǎn) InputOutputArray outImage,//輸出圖像 const Scalar& color=Scalar::all(-1), //關(guān)鍵點(diǎn)的顏色 int flags=DrawMatchesFlags::DEFAULT //設(shè)置繪圖功能的標(biāo)志 );
函數(shù)drawKeypoints()用來繪制關(guān)鍵點(diǎn)。
SURF特征檢測示例:
#include<opencv2/opencv.hpp>
#include<opencv2/xfeatures2d.hpp>
using namespace cv;
using namespace cv::xfeatures2d;
Mat src;
int minHessian = 50;
void trackBar(int, void*);
int main()
{
src = imread("E:/image/image/bdb.jpg");
if (src.empty())
{
printf("can not load image \n");
return -1;
}
namedWindow("input", WINDOW_AUTOSIZE);
imshow("input", src);
namedWindow("output", WINDOW_AUTOSIZE);
createTrackbar("minHessian","output",&minHessian, 500, trackBar);
waitKey(0);
return 0;
}
void trackBar(int, void*)
{
Mat dst;
// SURF特征檢測
Ptr<SURF> detector = SURF::create(minHessian);
std::vector<KeyPoint> keypoints;
detector->detect(src, keypoints, Mat());
// 繪制關(guān)鍵點(diǎn)
drawKeypoints(src, keypoints, dst, Scalar::all(-1), DrawMatchesFlags::DEFAULT);
imshow("output", dst);
}


以上這篇opencv3/C++ 實(shí)現(xiàn)SURF特征檢測就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
- C++?opencv圖像處理實(shí)現(xiàn)圖片邊緣檢測示例
- C++ OpenCV實(shí)戰(zhàn)之網(wǎng)孔檢測的實(shí)現(xiàn)
- C++ OpenCV實(shí)戰(zhàn)之標(biāo)記點(diǎn)檢測的實(shí)現(xiàn)
- C++?OpenCV實(shí)戰(zhàn)之車道檢測
- C++?OpenCV實(shí)現(xiàn)二維碼檢測功能
- C++ opencv霍夫圓檢測使用案例詳解
- opencv3/C++實(shí)現(xiàn)霍夫圓/直線檢測
- C++利用opencv實(shí)現(xiàn)人臉檢測
- C++利用Opencv實(shí)現(xiàn)多個圓形檢測
相關(guān)文章
c語言實(shí)現(xiàn)輸入一組數(shù)自動從大到小排列的實(shí)例代碼
下面小編就為大家?guī)硪黄猚語言實(shí)現(xiàn)輸入一組數(shù)自動從大到小排列的實(shí)例代碼。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-09-09
C++實(shí)現(xiàn)LeetCode(136.單獨(dú)的數(shù)字)
這篇文章主要介紹了C++實(shí)現(xiàn)LeetCode(136.單獨(dú)的數(shù)字),本篇文章通過簡要的案例,講解了該項(xiàng)技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下2021-07-07
C語言中常見的六種動態(tài)內(nèi)存錯誤總結(jié)
學(xué)習(xí)過C語言中的動態(tài)內(nèi)存函數(shù),例如【malloc】、【calloc】、【realloc】、【free】,那它們在使用的過程中會碰到哪些問題呢,本本文我們一起來探討下,感興趣的朋友跟著小編一起來看看吧2023-11-11
C/C++函數(shù)參數(shù)聲明解析int?fun()?與?int?fun(void)?的區(qū)別講解
C++中int fun()和int fun(void)的區(qū)別在于函數(shù)參數(shù)的聲明方式,前者默認(rèn)允許任意參數(shù),而后者表示沒有參數(shù),通過清晰的實(shí)例源代碼,詳細(xì)解釋了它們在函數(shù)聲明和調(diào)用中的不同之處,這篇文章介紹了C/C++函數(shù)參數(shù)聲明int?fun()與int?fun(void)的差異,需要的朋友可以參考下2024-01-01

