【问题标题】:After adding SurfFeatureDetector, program giving error添加 SurfFeatureDetector 后,程序报错
【发布时间】:2017-10-16 01:54:58
【问题描述】:

我正在使用opencv 3.3.0

我的代码是

#include <stdio.h>
#include <iostream>
#include "opencv2/core.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/features2d.hpp"
#include "opencv2/xfeatures2d.hpp"
#include <fstream>
#include <string>
#include <vector>

using namespace cv;
using namespace std;
using namespace cv::xfeatures2d;

int main(int argc, char** argv)
{
    Mat img1;
    img1 = imread("img/img1.jpg", IMREAD_GRAYSCALE);

    if (img1.empty())
    {
        cout << "Could not open or find the image" << endl;
        return -1;
    }

    Ptr<SurfFeatureDetector> detector = SurfFeatureDetector::create(400);
    vector<KeyPoint> keypoints;
    detector->detect(img1, keypoints);

    imshow("img1", img1);
    waitKey(0);
    return 0;
}

我是 C++opencv 的新手。该代码在没有 surf 部分的情况下运行良好。

错误

OpenCV 错误:cv::TlsAbstraction::SetData 文件 C:\Users\Darshana\Documents\opencv\opencv-3.3.0\modules\core\ 中的断言失败 (TlsSetValue(tlsKey, pData) == TRUE) src\system.cpp,第 1270 行

我也试过Ptr&lt;SURF&gt; detector = SURF::create(400);

更新

我想不出解决办法。也许是设置问题或库问题。所以我只是搬到opencv 2.4.13,现在一切正常。不过,我必须更改上面的代码才能使用v2.4.13

【问题讨论】:

  • 如果您投反对票,请说明原因。

标签: c++ opencv surf


【解决方案1】:

您还没有为SurfFeatureDetector 设置参数。我认为你应该试试这个:

int minHessian = 400;
SurfFeatureDetector detector(minHessian);
vector<KeyPoint> keypoints;
detector.detect(img1, keypoints);

【讨论】:

  • 我已经试过了。这不适用于opencv 3.3.0。它给出了编译错误。
  • 哦,我用opencv 2.4.13SURFSurfFeatureDetectorSurfDescriptorExtractor是一样的。
猜你喜欢
  • 2015-10-02
  • 2012-06-23
  • 1970-01-01
  • 2022-08-18
  • 2017-05-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-11-02
相关资源
最近更新 更多