-1

我正在尝试按照本教程进行对象检测,但我一开始就卡住了。

到目前为止,我的代码是这样的:

#include <stdio.h>
#include <stdlib.h>

#include <opencv2/opencv.hpp>
#include <fstream>
#include <iostream>
#include <string>

#include <dirent.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>

using namespace cv;
using namespace std;

int main() {

    Ptr<DescriptorExtractor> extractor = DescriptorExtractor::create("SURF");
    //Mat training_descriptors(1, extractor->descriptorSize(), extractor->descriptorType());

    extractor->descriptorSize();

    return 0;
}

以下行extractor->descriptorSize();给出了分段错误(核心转储),我不知道为什么。你有什么想法?

4

1 回答 1

2

我发现没有安装 OpenCV 的非自由模块。安装后,我包含了非自由库#include <opencv2/nonfree/nonfree.hpp>,然后调用了cv::initModule_nonfree();. 问题已经解决了。

于 2014-12-30T22:03:47.547 回答