FAST
写法很简单,第一次见到比python写法还简单的函数
vector<KeyPoint> kps;
FAST(f1, kps, 10);
if (kps.size()>0) {
drawKeypoints(frame, kps, f2,Scalar::all(-1),DrawMatchesFlags::DEFAULT);
}
https://blog.csdn.net/holybin/article/details/44734011
将特征关联起来
int nrows = getOptimalDFTSize(frame.rows);
int ncols = getOptimalDFTSize(frame.cols);
resize(frame, frame, {nrows,ncols});
nrows = getOptimalDFTSize(f2.rows);
ncols = getOptimalDFTSize(f2.cols);
resize(f2, f2, {nrows,ncols});
cvtColor(frame, frame, COLOR_BGRA2BGR);
cvtColor(f2, f2, COLOR_BGRA2BGR);
f1 = Mat::ones(frame.size(), frame.type());
f3 = Mat::ones(f2.size(), f2.type());
f4 = Mat::ones(frame.size(), frame.type());
vector<KeyPoint> keys1,keys2;
Ptr<FeatureDetector> fast1=FastFeatureDetector::create(40);
Ptr<FeatureDetector> fast2=FastFeatureDetector::create(40);
fast1->detect(frame, keys1);
fast1->detect(f2, keys2);
drawKeypoints(frame, keys1, f1,Scalar::all(-1),DrawMatchesFlags::DRAW_OVER_OUTIMG);
drawKeypoints(f2, keys2, f3,Scalar::all(-1),DrawMatchesFlags::DRAW_OVER_OUTIMG);
Ptr<ORB> orb = ORB::create();
Mat des1,des2;
orb->compute(frame, keys1, des1);//noArray()
orb->compute(f2, keys2, des2);
BFMatcher bfm = BFMatcher(NORM_HAMMING,true);
vector<DMatch> match;
bfm.match(des1, des2,match);
if(match.size()==0){
NSLog(@"no match~!!!");
}
drawMatches(frame, keys1, f2, keys2, match, f4,Scalar::all(-1),DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS);
https://ask.csdn.net/questions/363642
SIFT 和 SURF
这两个特征查找算法是有专利费的,所以在opencv v3中没包含,是放在在扩展包的nonfree中 (opencv v2中包含)