|
发表于 2016-9-10 14:20:31
|
显示全部楼层
opencv 3.0 开始把 sift surf library 移动到 <xfeature2d\nonfree.hpp>里, 需要include 头文件。
当然makefile 时一定要加上 contrib 那个一起编译。
使用方法和orb 很像
// 创建方式为 sift 和 surf 方式一样 xfeatures2d::sift 可以申请
Ptr <xfeatures2d::SURF> detector = xfeatures2d::SURF::create(50, 1, 1, false, false);
keypoint initial
detector->detect(srcImage1, keyPoint1);
detector->detect(srcImage2, keyPoint2);
compute initial
detector->compute(srcImage1, keyPoint1, descriptorMat1);
detector->compute(srcImage2, keyPoint2, descriptorMat2);
FlannBasedMatcher matcher;
std::vector<DMatch> mathces;
matcher.match(descriptorMat1, descriptorMat2, mathces);
Mat matchMat;
drawMatches(srcImage1, keyPoint1,
srcImage2, keyPoint2, mathces, matchMat);
cv::imshow("Mathces", matchMat);
|
|