SIFT特征检测器产生未处理的异常

时间:2012-10-31 01:00:52

标签: opencv sift

以下代码仅用于查看SIFT中的功能检测。问题是当我运行它时会中断。

#include <features2d.hpp>
#include <stdafx.h>
#include <stdlib.h>
#include <cv.hpp>
#include <cxcore.hpp>
#include <highgui.h>
#include <iostream>


using namespace cv;
using namespace std;


int _tmain(int argc, _TCHAR* argv[])
{
    Mat img = imread("c:\\chappal.jpg", 0);
    Ptr<FeatureDetector> feature_detector = FeatureDetector::create("SIFT");
    vector<KeyPoint> keypoints;

    feature_detector->detect(img, keypoints);

    Mat output;

    drawKeypoints(img, keypoints, output, Scalar(255, 0, 0));

    namedWindow("meh", CV_WINDOW_AUTOSIZE);
    imshow("meh", output);
    waitKey(0);



    return 0;
}

当逐步调试时,程序会在此行中断:feature_detector->detect(img, keypoints);

我一次又一次地检查过,不知道问题可能是由什么造成的。

P.S。我首先尝试使用SiftFeatureDetector代替FeatureDetector::create("SIFT");,但遇到了错误,因为它在库文件中找不到SiftFeatureDetector。我从这个论坛的帖子中了解了两个代码示例。

谢谢

1 个答案:

答案 0 :(得分:1)

我不知道你是否尝试过这个,但由于它现在在nonfree.h库中,你需要使用initModule_nonfree()。这解决了我的问题。