OpenCV中文网站

 找回密码
 立即注册
搜索
热搜: 安装 配置
12
返回列表 发新帖
楼主: whitelee

VS2013编译opencv3.1+opencv_contrib成功,但调用SURF算法出错。

[复制链接]
发表于 2016-11-2 22:15:27 | 显示全部楼层
本帖最后由 jennifer-jl 于 2016-11-2 22:20 编辑
  1. #include<opencv2\core.hpp>
  2. #include<opencv2\highgui.hpp>
  3. #include<opencv2/imgproc.hpp>
  4. #include<opencv2/xfeatures2d.hpp>

  5. int main()
  6. {
  7.         cv::Mat image = cv::imread("church01.jpg",0);
  8.         cv::Ptr<cv::xfeatures2d::SURF> surf;
  9.         surf=cv::xfeatures2d::SURF::create(2500.);
  10.         std::vector<cv::KeyPoint> keyPoint;
  11.         surf->detect(image,keyPoint);
  12.         cv::Mat result1;
  13.         cv::drawKeypoints(image, keyPoint, result1,cv::Scalar(255,255,255),cv::DrawMatchesFlags::DRAW_RICH_KEYPOINTS);

  14.         cv::Mat image2 = cv::imread("church03.jpg", 0);
  15.         cv::Ptr<cv::xfeatures2d::SURF> surf3;
  16.         surf3 = cv::xfeatures2d::SURF::create(2500.);
  17.         std::vector<cv::KeyPoint> keyPoint3;
  18.         surf->detect(image2, keyPoint3);
  19.         cv::Mat result3;
  20.         cv::drawKeypoints(image2, keyPoint3, result3, cv::Scalar(255, 255, 255), cv::DrawMatchesFlags::DRAW_RICH_KEYPOINTS);

  21.         cv::Mat description;
  22.         surf->compute(image, keyPoint, description);
  23.         cv::Mat description3;
  24.         surf3->compute(image2, keyPoint3, description3);
  25.         cv::Ptr<cv::BFMatcher> matcher =new cv::BFMatcher();

  26.         std::vector<cv::DMatch> matchs;
  27.         matcher->match(description, description3, matchs);
  28.         std::nth_element(matchs.begin(), matchs.begin() + 24, matchs.end());
  29.         matchs.erase(matchs.begin() + 25, matchs.end());
  30.         cv::Mat MatchPicture;
  31.         cv::drawMatches(image, keyPoint, image2, keyPoint3, matchs, MatchPicture);

  32.                 return 0;
  33. }</div>
复制代码

我今天也是研究了一整天,代码终于正确了。下面,我把代码粘贴下来:
//opencv3.1.0
//opencv_contrib



}

回复 支持 反对

使用道具 举报

发表于 2017-2-11 12:15:12 | 显示全部楼层
fengever 发表于 2016-10-5 11:56
前一阵子刚搞定,有什么问题可以找我

你的opencv3.1+contrib编译成功了,编译好久始终不成功,能否发一份编译好的。谢谢,289386886@qq.com
回复 支持 反对

使用道具 举报

发表于 2017-2-11 12:15:50 | 显示全部楼层
fengever 发表于 2016-10-5 11:56
前一阵子刚搞定,有什么问题可以找我

你的opencv3.1+contrib编译成功了,编译好久始终不成功,能否发一份编译好的。谢谢,289386886@qq.com
回复 支持 反对

使用道具 举报

发表于 2019-3-26 16:49:25 | 显示全部楼层
takemegod 发表于 2016-9-10 14:20
**** 作者被禁止或删除 内容自动屏蔽 ****

请教一下,我用的是opencv4.0.1,添加了opencv_contrib后,使用surf算法进行检测时出现如下问题: Error: The function/feature is not implemented (This algorithm is patented and is excluded in this configuration; Set OPENCV_ENABLE_NONFREE CMake option and rebuild the library) in cv::xfeatures2d::SIFT::create。请问这是什么原因?
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|OpenCV中文网站

GMT+8, 2024-4-27 07:11 , Processed in 0.008527 second(s), 13 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表