91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

在windows上利用OpenCV和vs2010實現了sift和surf粗配準,利用Ransac實現精確配準,C++源碼,可以運行。

資源截圖

代碼片段和文件信息

#include?
#include?
#include???
#include???
#include?
#include?
#include???
#include???

using?namespace?cv;?
using?namespace?std;?

int?main()
{
initModule_nonfree();//初始化模塊,使用SIFT或SURF時用到?
Ptr?detector?=?FeatureDetector::create(?“SURF“?);//創建SIFT特征檢測器,可改成SURF/ORB
PtrriptorExtractor>?descriptor_extractor?=?DescriptorExtractor::create(?“SURF“?);//創建特征向量生成器,可改成SURF/ORB
PtrriptorMatcher>?descriptor_matcher?=?DescriptorMatcher::create(?“BruteForce“?);//創建特征匹配器??
if(?detector.empty()?||?descriptor_extractor.empty()?)??
cout<<“fail?to?create?detector!“;??

//讀入圖像??
Mat?img1?=?imread(“C://Users//YYL//Desktop//c_FourCamera_Match//SIFT_RANSAC//TestImage//Pair2//1.JPG“);??
Mat?img2?=?imread(“C://Users//YYL//Desktop//c_FourCamera_Match//SIFT_RANSAC//TestImage//Pair2//2.JPG“);??

//特征點檢測??
double?t?=?getTickCount();//當前滴答數??
vector?m_LeftKeym_RightKey;??
detector->detect(?img1?m_LeftKey?);//檢測img1中的SIFT特征點,存儲到m_LeftKey中??
detector->detect(?img2?m_RightKey?);??
cout<<“圖像1特征點個數:“< cout<<“圖像2特征點個數:“<
//根據特征點計算特征描述子矩陣,即特征向量矩陣??
Mat?descriptors1descriptors2;??
descriptor_extractor->compute(?img1?m_LeftKey?descriptors1?);??
descriptor_extractor->compute(?img2?m_RightKey?descriptors2?);??
t?=?((double)getTickCount()?-?t)/getTickFrequency();??
cout<<“SIFT算法用時:“<
cout<<“圖像1特征描述矩陣大小:“<riptors1.size()??
<<“,特征向量個數:“<riptors1.rows<<“,維數:“<riptors1.cols< cout<<“圖像2特征描述矩陣大小:“<riptors2.size()??
<<“,特征向量個數:“<riptors2.rows<<“,維數:“<riptors2.cols<
//畫出特征點??
Mat?img_m_LeftKeyimg_m_RightKey;??
drawKeypoints(img1m_LeftKeyimg_m_LeftKeyScalar::all(-1)0);??
drawKeypoints(img2m_RightKeyimg_m_RightKeyScalar::all(-1)0);??
//imshow(“Src1“img_m_LeftKey);??
//imshow(“Src2“img_m_RightKey);??

//特征匹配??
vector?matches;//匹配結果??
descriptor_matcher->match(?descriptors1?descriptors2?matches?);//匹配兩個圖像的特征矩陣??
cout<<“Match個數:“<
//計算匹配結果中距離的最大和最小值??
//距離是指兩個特征向量間的歐式距離,表明兩個特征的差異,值越小表明兩個特征點越接近??
double?max_dist?=?0;??
double?min_dist?=?100;??
for(int?i=0;?i {??
double?dist?=?matches[i].distance;??
if(dist? if(dist?>?max_dist)?max_dist?=?dist;??
}??
cout<<“最大距離:“< cout<<“最小距離:“<
//篩選出較好的匹配點??
vector?goodMatches;??
for(int?i=0;?i {??
if(matches[i].distance? {??
goodMatches.push_back(matches[i]);??
}??
}??
cout<<“goodMatch個數:“<
//畫出匹配結果??
Mat?img_matches;??
//紅色連接的是匹配的特征點對,綠色是未匹配的特征點??
drawMatches(img1m_LeftKeyimg2m_RightKeygoodMa

評論

共有 條評論