我正在使用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
的新手。该代码在没有冲浪部分的情况下运行良好。
错误
OpenCV错误:cv :: TlsAbstraction :: SetData中的断言失败(TlsSetValue(tlsKey,pData)== TRUE),文件C:\ Users \ Darshana \ Documents \ opencv \ opencv-3.3.0 \ modules \ core \ src \ system.cpp,第1270行
我也试过了Ptr<SURF> detector = SURF::create(400);
。
更新
我无法找到解决方案。可能是设置问题或库问题。所以我转到opencv 2.4.13
,现在一切正常。我必须更改上面的代码才能使用v2.4.13
。
答案 0 :(得分:0)
您尚未为SurfFeatureDetector
设置参数。我想你应该试试这个:
int minHessian = 400;
SurfFeatureDetector detector(minHessian);
vector<KeyPoint> keypoints;
detector.detect(img1, keypoints);