surf與sift特徵點檢測程式碼實現
概述
在opencv的features2d中實現了SIFT和SURF演算法,可以用於影象特徵點的自動檢測。具體實現是採用SurfFeatureDetector/SiftFeatureDetector類的detect函式檢測SURF/SIFT特徵的關鍵點,並儲存在vector容器中,最後使用drawKeypoints函式繪製出特徵點。
實驗所用環境是opencv2.4.0+vs2008+win7,測試圖片是:
SURF特徵點檢測
實驗程式碼如下。這裡需要注意SurfFeatureDetector是包含在opencv2/nonfree/features2d.hpp中,所以應該include這個標頭檔案,並且在“專案屬性->連結器->輸入->附加依賴項”中加入庫檔案:opencv_nonfree240d.lib。
- /**
- * @SURF特徵點檢測並繪製特徵點
- * @author holybin
- */
- #include <stdio.h>
- #include <iostream>
- #include "opencv2/core/core.hpp"
- #include "opencv2/highgui/highgui.hpp"
- //#include "opencv2/features2d/features2d.hpp"
- #include "opencv2/nonfree/features2d.hpp" //SurfFeatureDetector實際在該標頭檔案中
- usingnamespace cv;
- usingnamespace std;
- int main( int argc, char** argv )
- {
- Mat src = imread( "D:\\opencv_pic\\cat3d120.jpg", 0 );
- //Mat src = imread( "D:\\opencv_pic\\cat0.jpg", 0 );
- if( !src.data )
- {
- cout<< " --(!) Error reading images "<<endl;
- return -1;
- }
- //1--初始化SURF檢測運算元
- int minHessian = 400;
- SurfFeatureDetector detector( minHessian );
- //2--使用SURF運算元檢測特徵點
- vector<KeyPoint> keypoints;
- detector.detect( src, keypoints );
- //3--繪製特徵點
- Mat keypointImg;
- drawKeypoints( src, keypoints, keypointImg, Scalar::all(-1), DrawMatchesFlags::DEFAULT );
- imshow("SURF keypoints", keypointImg );
- cout<<"keypoint number: "<<keypoints.size()<<endl;
- waitKey(0);
- return 0;
- }
/**
* @SURF特徵點檢測並繪製特徵點
* @author holybin
*/
#include <stdio.h>
#include <iostream>
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
//#include "opencv2/features2d/features2d.hpp"
#include "opencv2/nonfree/features2d.hpp" //SurfFeatureDetector實際在該標頭檔案中
using namespace cv;
using namespace std;
int main( int argc, char** argv )
{
Mat src = imread( "D:\\opencv_pic\\cat3d120.jpg", 0 );
//Mat src = imread( "D:\\opencv_pic\\cat0.jpg", 0 );
if( !src.data )
{
cout<< " --(!) Error reading images "<<endl;
return -1;
}
//1--初始化SURF檢測運算元
int minHessian = 400;
SurfFeatureDetector detector( minHessian );
//2--使用SURF運算元檢測特徵點
vector<KeyPoint> keypoints;
detector.detect( src, keypoints );
//3--繪製特徵點
Mat keypointImg;
drawKeypoints( src, keypoints, keypointImg, Scalar::all(-1), DrawMatchesFlags::DEFAULT );
imshow("SURF keypoints", keypointImg );
cout<<"keypoint number: "<<keypoints.size()<<endl;
waitKey(0);
return 0;
}
檢測結果:
SIFT特徵點檢測
同樣的,使用SIFT特徵描述子進行特徵點檢測的過程類似,只不過換成了SiftFeatureDetector類,實驗程式碼如下:
[cpp] view plaincopyprint?- /**
- * @SIFT特徵點檢測並繪製特徵點
- * @author holybin
- */
- #include <stdio.h>
- #include <iostream>
- #include "opencv2/core/core.hpp"
- #include "opencv2/highgui/highgui.hpp"
- //#include "opencv2/features2d/features2d.hpp"
- #include "opencv2/nonfree/features2d.hpp" //SiftFeatureDetector實際在該標頭檔案中
- usingnamespace cv;
- usingnamespace std;
- int main( int argc, char** argv )
- {
- Mat src = imread( "D:\\opencv_pic\\cat3d120.jpg", 0 );
- //Mat src = imread( "D:\\opencv_pic\\cat0.jpg", 0 );
- if( !src.data )
- {
- cout<< " --(!) Error reading images "<<endl;
- return -1;
- }
- //1--初始化SIFT檢測運算元
- //int minHessian = 400;
- SiftFeatureDetector detector;//( minHessian );
- //2--使用SIFT運算元檢測特徵點
- vector<KeyPoint> keypoints;
- detector.detect( src, keypoints );
- //3--繪製特徵點
- Mat keypointImg;
- drawKeypoints( src, keypoints, keypointImg, Scalar::all(-1), DrawMatchesFlags::DEFAULT );
- imshow("SIFT keypoints", keypointImg );
- cout<<"keypoint number: "<<keypoints.size()<<endl;
- waitKey(0);
- return 0;
- }
/**
* @SIFT特徵點檢測並繪製特徵點
* @author holybin
*/
#include <stdio.h>
#include <iostream>
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
//#include "opencv2/features2d/features2d.hpp"
#include "opencv2/nonfree/features2d.hpp" //SiftFeatureDetector實際在該標頭檔案中
using namespace cv;
using namespace std;
int main( int argc, char** argv )
{
Mat src = imread( "D:\\opencv_pic\\cat3d120.jpg", 0 );
//Mat src = imread( "D:\\opencv_pic\\cat0.jpg", 0 );
if( !src.data )
{
cout<< " --(!) Error reading images "<<endl;
return -1;
}
//1--初始化SIFT檢測運算元
//int minHessian = 400;
SiftFeatureDetector detector;//( minHessian );
//2--使用SIFT運算元檢測特徵點
vector<KeyPoint> keypoints;
detector.detect( src, keypoints );
//3--繪製特徵點
Mat keypointImg;
drawKeypoints( src, keypoints, keypointImg, Scalar::all(-1), DrawMatchesFlags::DEFAULT );
imshow("SIFT keypoints", keypointImg );
cout<<"keypoint number: "<<keypoints.size()<<endl;
waitKey(0);
return 0;
}
檢測結果:
從檢測結果可以看出,SURF運算元檢測到的特徵點遠遠多於SIFT運算元,至於檢測的精確度如何,後面試試利用SIFT和SURF運算元進行特徵點匹配來區分。
相關推薦
surf與sift特徵點檢測程式碼實現
概述 在opencv的features2d中實現了SIFT和SURF演算法,可以用於影象特徵點的自動檢測。具體實現是採用SurfFeatureDetector/SiftFeatureDetector類的detect函式檢測SURF/SIFT特徵的關鍵點,並儲
opencv學習筆記二十九:SIFT特徵點檢測與匹配
SIFT(Scale-invariant feature transform)是一種檢測區域性特徵的演算法,該演算法通過求一幅圖中的特徵點(interest points,or corner points)及其有關scale 和 orientation 的描述子得到特徵並進行
SIFT特徵點檢測學習一(轉載)
sift演算法在cv領域的重要性不言而喻,該作者的文章引用率在cv界是number1.本篇部落格只是本人把sift演算法知識點整理了下,以免忘記。本文比較早的一篇博文opencv原始碼解析之(3):特徵點檢查前言1 中有使用opencv自帶的sift做了個簡單的實驗,而這次主要是利用Rob Hes
SIFT特徵點檢測,特徵點描述,特徵點匹配理解
前面提到了Harris角點檢測,此方法一個很明顯的缺點是不能解決尺度變化不變性,因為Harris中檢測一個點是不是角點是看這個點所在patch和周圍各個方向patch是否有明顯變化,可是尺度變化後這個方法不適用,SIFT利用差分高斯金字塔解決了這個問題。SIFT特徵點檢測步驟
UMDFaces資料集與人臉特徵點檢測
UMDFaces資料集: 該資料集包含367920張人臉,分別類屬於8501個事件類別。提供的人臉資訊包括,人臉框,人臉姿勢,(yaw,pitch,roll),21個關鍵點,性別資訊等。由於圖片尺度,方向等的問題,使得該資料集不適合做人臉檢測的訓練,適合做人臉識別。 該
OpenCV中feature2D學習——FAST特徵點檢測與SIFT/SURF/BRIEF特徵提取與匹配
在前面的文章《OpenCV中feature2D學習——FAST特徵點檢測》中講了利用FAST運算元進行特徵點檢測,這裡嘗試使用FAST運算元來進行特徵點檢測,並結合SIFT/SURF/BRIEF運算元進行特徵點提取和匹配。 I、結合SIFT運算元進行特徵點提取
OpenCV中feature2D學習——SURF和SIFT運算元實現特徵點檢測
概述 在opencv的features2d中實現了SIFT和SURF演算法,可以用於影象特徵點的自動檢測。具體實現是採用SurfFeatureDetector/SiftFeatureDetector類的detect函式檢測SURF/SIFT特徵的關鍵點,並儲存
SURF特徵點檢測與匹配之誤匹配點刪除
SURF特徵點檢測與匹配之誤匹配點刪除 SURF(SpeededUp Robust Feature)是加速版的具有魯棒性的演算法,是SIFT演算法的加速版。 但是SURF特徵匹配之後有大量的誤匹配點,需要對這些誤匹配點進行刪除。 這裡不從理論上講解SURF原理等,直接說用
【OpenCV學習筆記】三十七、特徵檢測與匹配(二)——SIFT特徵點匹配
特徵檢測與匹配(二)——SIFT特徵點匹配 1.SIFT特徵點提取 2.繪製特徵點 3.特徵點描述符(特徵向量)提取 4.使用暴力匹配器進行暴力匹配 5.對匹配結果進行篩選(依據DMatch結構體中的float型別變數distance進行篩選) 6.繪製匹配結果 先上ppt
Surf特徵點檢測與匹配
#include <opencv2\core\core.hpp> #include <opencv2\highgui\highgui.hpp> #include <opencv2\nonfree\features2d.hpp> #incl
Surf演算法特徵點檢測與匹配
Speeded Up Robust Features(SURF,加速穩健特徵),是一種穩健的區域性特徵點檢測和描述演算法。最初由Herbert Bay發表在2006年的歐洲計算機視覺國際會議(Europen Conference on Computer Vision,EC
opencv(30)---特徵檢測與匹配(1)---SIFT特徵點提取
基本概念 特徵點的檢測和匹配是計算機視覺中非常重要的技術之一, 在物體識別、視覺跟蹤、三維重建等領域都有很廣泛的應用。OpenCV提供瞭如下幾種特徵檢測方法: “FAST”——FastFeatureDetector “STAR”——StarFeatureD
【opencv】特徵點檢測方法--GFTT,SIFT,FAST,SURF
一. 特徵點檢測方法總結 二.關於特徵點分析對比的相關論文 1. 有關特徵點:Shi-Tmoasi,SIFT,SURF 方法:基於opencv,通過RGB分解,比較特徵點的個數和魯棒性 2. 有關特徵點:FAST 方法:主要是
第二篇:基於深度學習的人臉特徵點檢測 - 資料與方法(轉載)
https://yinguobing.com/facial-landmark-localization-by-deep-learning-data-and-algorithm/ 在上一篇博文中,我們瞭解了人臉檢測與面部特徵點檢測的背景,並提到了當前技術方案存在特徵點位置不穩定的缺點,需要新的解決
opencv學習筆記三十六:AKAZE特徵點檢測與匹配
KAZE是日語音譯過來的 , KAZE與SIFT、SURF最大的區別在於構造尺度空間,KAZE是利用非線性方式構造,得到的關鍵點也就更準確(尺度不變性 ); Hessian矩陣特徵點檢測 ,方向指定,基於一階微分影象(旋轉不變性 ) ; 描述子生成 ,歸一化處理(光照不變
【OpenCV入門教程之十七】OpenCV重對映 SURF特徵點檢測合輯
本篇文章中,我們一起探討了OpenCV中重對映和SURF特徵點檢測相關的知識點,主要一起了解OpenCV中重對映相關的函式remap,SURF演算法在OpenCV中的體現與應用。此博文一共有三個配套的麻雀雖小但五臟俱全的示例程式,其經過淺墨詳細註釋過的程式碼都在文中貼出,且文章
FAST特徵點檢測的matlab實現
FAST特徵點檢測的matlab原始碼實現 1. 簡介 2. FAST的原理介紹 2.1 特徵點檢測 2.2 極值點抑制 3. matlab原始碼實現 4. 結果展示 1. 簡介 Features
特徵點檢測學習_2(surf演算法)
在上篇部落格特徵點檢測學習_1(sift演算法) 中簡單介紹了經典的sift演算法,sift演算法比較穩定,檢測到的特徵點也比較多,其最大的確定是計算複雜度較高。後面有不少學者對其進行了改進,其中比較出名的就是本文要介紹的surf演算法,surf的中文意思為快速魯棒特徵。本
OpenCV特徵點檢測------Surf(特徵點篇)
Surf(Speed Up Robust Feature)Surf演算法的原理 1.構建Hessian矩陣構造高斯金字塔尺度空間其
特徵點檢測學習(surf演算法)
在上篇部落格特徵點檢測學習_1(sift演算法) 中簡單介紹了經典的sift演算法,sift演算法比較穩定,檢測到的特徵點也比較多,其最大的確定是計算複雜度較高。後面有不少學者對其進行了改進,其中比較出名的就是本文要介紹的surf演算法,surf的中文意思為快速魯