OpenCV SURF功能未实现

2024-04-21

当我尝试运行示例时find_obj.cpp或任何 OpenCV SURF 程序,在执行代码时,我在命令提示符中收到以下错误。该项目构建时没有错误和警告。我使用的是 VS2011 beta、OpenCV 2.4 和 windows7。

错误信息:

OpenCV Error: The function/feature is not implemented < OpenCV was built without SURF support> in unknown function,file ..\..\..\src\opencv\modules\legacy\src\features2d.cpp, line 77

我尝试使用 Cmake 再次构建 OpenCV 2.4,然后在调试模式下使用 VS2011 构建 OpenCV 2.4,然后在 IDE 中添加 lib 路径,但仍然没有结果。

我该如何解决这个问题?

    #include <opencv2/objdetect/objdetect.hpp>
    #include <opencv2/features2d/features2d.hpp>
    #include <opencv2/core/core.hpp>
    #include <opencv2/highgui/highgui.hpp>
    #include <opencv2/legacy/legacy.hpp>
    #include <opencv2/legacy/compat.hpp>
    #include <opencv2/flann/flann.hpp>
    #include <opencv2/calib3d/calib3d.hpp>
    #include <opencv2/nonfree/features2d.hpp>
    #include <opencv2/nonfree/nonfree.hpp>

using namespace std;
using namespace cv;
int main()
{
    cv::initModule_nonfree();//THIS LINE IS IMPORTANT   

   IplImage *image1 = cvLoadImage("C:\\SURF\\1.jpg"); 
    IplImage *image2 = cvLoadImage("C:\\SURF\\2.jpg");

    CvMemStorage* memoryBlock = cvCreateMemStorage();
    CvSeq* image1KeyPoints;
    CvSeq* image1Descriptors;
    CvSeq* image2KeyPoints;
    CvSeq* image2Descriptors;

    // Only values with a hessian greater than 500 are considered for keypoints
   CvSURFParams params = cvSURFParams(500, 1);
   cvExtractSURF(image1, 0, &image1KeyPoints, &image1Descriptors, memoryBlock, params);
   cvExtractSURF(image2, 0, &image2KeyPoints, &image2Descriptors, memoryBlock, params);

   return 0;
}

取自这个答案 http://opencv-users.1802565.n2.nabble.com/OpenCV-installation-with-SURF-feature-support-on-Ubuntu-td7580412.html(为什么在提问之前不先用谷歌搜索一下你的问题?):

SIFT 和 SURF 代码在 OpenCV v2.4 中移至名为的新模块nonfree。确保您链接(Windlows 中的 DLL)到它。在linux中这个库被称为libopencv_nonfree.so.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

OpenCV SURF功能未实现 的相关文章

随机推荐