了解了SIFT特征后,来学习SURF特征。
虽说是SIFT的一个变种,可是跟SIFT还是有差别的
差别有例如以下:
1.尺度空间的构建(近似)不同。
2.同意尺度空间多层图像同一时候被处理
3.特征点主方向确定採用haar小波特征统计方法。
4.特征点描写叙述子採用haar小波特征。
接下来贴个SURF匹配代码:
// Load image from file IplImage *pLeftImage = cvLoadImage("1.jpg", CV_LOAD_IMAGE_GRAYSCALE); IplImage *pRightImage = cvLoadImage("2.jpg", CV_LOAD_IMAGE_GRAYSCALE); // Convert IplImage to cv::Mat Mat matLeftImage = Mat(pLeftImage, false); // Mat matRightImage = Mat(pRightImage, false); // Key point and its descriptor vector<KeyPoint> LeftKey; vector<KeyPoint> RightKey; Mat LeftDescriptor; Mat RightDescriptor; vector<DMatch> Matches; // Detect key points from image FeatureDetector *pDetector = new SurfFeatureDetector; // 这里我们用了SURF特征点 pDetector->detect(matLeftImage, LeftKey); pDetector->detect(matRightImage, RightKey); // delete pDetector; // Extract descriptors DescriptorExtractor *pExtractor = new SurfDescriptorExtractor; // 提取SURF描写叙述向量 pExtractor->compute(matLeftImage, LeftKey, LeftDescriptor); pExtractor->compute(matRightImage, RightKey, RightDescriptor); //delete pExtractor; // Matching features DescriptorMatcher *pMatcher = new FlannBasedMatcher; // 使用Flann匹配算法 pMatcher->match(LeftDescriptor, RightDescriptor, Matches); //delete pMatcher; // Show result Mat OutImage; drawMatches(matLeftImage, LeftKey, matRightImage, RightKey, Matches, OutImage); cvNamedWindow( "SURF Match features", 1); cvShowImage("SURF Match features", &(IplImage(OutImage))); cvWaitKey( 0 ); cvDestroyWindow( "SURF Match features" ); return 0;
调试一下:
两幅图像分别生成SURF特征描写叙述子。
当然也可看到当中的值。
做这个也仅仅是想表达一下 ,OpenCV结合VS能够做到跟MATLAB一样的效果。。。。
SURF学习相关链接:
http://blog.csdn.net/andkobe/article/details/5778739
http://blog.csdn.net/crzy_sparrow/article/details/7392345
http://www2.ulg.ac.be/telecom/research/vibe/download.html
原文:http://www.cnblogs.com/hrhguanli/p/3841578.html