opencv示例不起作用(detector_descriptors_evaluation.cpp)

时间:2014-02-10 11:43:28

标签: opencv feature-extraction

我想在OpenCV中使用opencv_extra数据集运行 detector_descriptor_evaluation.cpp 示例。但是,我得到关于SIFT,SURF探测器的错误,我不能使用匹配器。我想知道是否有人会解释这些问题。

main函数使用不同的检测器和/或匹配器类型创建DetectorQualityEvaluator类的对象,如下所示:

Ptr<BaseQualityEvaluator> evals[] =
{
    new DetectorQualityEvaluator( "FAST", "quality-detector-fast" ),
    new DetectorQualityEvaluator( "GFTT", "quality-detector-gftt" ),
    new DetectorQualityEvaluator( "HARRIS", "quality-detector-harris" ),
    new DetectorQualityEvaluator( "MSER", "quality-detector-mser" ),
    new DetectorQualityEvaluator( "STAR", "quality-detector-star" ),
    new DetectorQualityEvaluator( "SIFT", "quality-detector-sift" ),
    new DetectorQualityEvaluator( "SURF", "quality-detector-surf" ),
    new DescriptorQualityEvaluator( "SIFT", "quality-descriptor-sift", "BruteForce" ),
    new DescriptorQualityEvaluator( "SURF", "quality-descriptor-surf", "BruteForce" ),
    new DescriptorQualityEvaluator( "FERN", "quality-descriptor-fern"),
    new CalonderDescriptorQualityEvaluator()
};

程序正常工作,直到SIFT和SURF检测器,但它给出“无法读取算法”错误。换句话说,我无法创建这些探测器。当我不创建SIFT和SURF探测器时

    //new DetectorQualityEvaluator( "SIFT", "quality-detector-sift" ),
    //new DetectorQualityEvaluator( "SURF", "quality-detector-surf" ),

我收到以下错误:

   OpenCV Error: Assertion failed (!extractor.empty() && !matcher.empty()) in VectorDescriptorMatcher, file /home/sy/opencv-2.4.8/modules/features2d/src/matchers.cpp, line 1089

当我使用以下代码

    //new DetectorQualityEvaluator( "SIFT", "quality-detector-sift" ),
    //new DetectorQualityEvaluator( "SURF", "quality-detector-surf" ),
    //new DescriptorQualityEvaluator( "SIFT", "quality-descriptor-sift", "BruteForce" ),
    //new DescriptorQualityEvaluator( "SURF", "quality-descriptor-surf", "BruteForce" ),
    new DescriptorQualityEvaluator( "FERN", "quality-descriptor-fern"),
    new CalonderDescriptorQualityEvaluator()

我也得到了下面的错误。我认为它不承认“FERN”匹配器。在此示例中只有CalonderDescriptor可用。

  OpenCV Error: Bad argument (Unknown matcher name) in create, file /home/sy/opencv-2.4.8/modules/features2d/src/matchers.cpp, line 488

此致

1 个答案:

答案 0 :(得分:2)

我遇到了完全相同的失败。经过一些调试后,我发现对于SIFT和SURF,你需要非自由模块,这是示例代码中缺少的。添加:

#include "opencv2/nonfree/nonfree.hpp"

然后在main()中插入以下内容:

cv::initModule_nonfree();

行之前:

Ptr<BaseQualityEvaluator> evals[] =

此致