2017-10-16 52 views
-1

我使用opencv 3.3.0加入SurfFeatureDetector之後,節目給錯誤

我的代碼是

#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 Error: Assertion failed (TlsSetValue(tlsKey, pData) == TRUE) in cv::TlsAbstraction::SetData, file C:\Users\Darshana\Documents\opencv\opencv-3.3.0\modules\core\src\system.cpp, line 1270

我與Ptr<SURF> detector = SURF::create(400);嘗試爲好。

UPDATE

我無法找出一個解決方案。也許是安裝問題或庫問題。所以我只是移動到opencv 2.4.13,現在一切正常。不過,我不得不改變上面的代碼來與v2.4.13一起工作。

+0

如果你投下了票,請提一個理由。 – Darshana

回答

0

您尚未設置SurfFeatureDetector的參數。我想你應該試試這個:

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

我已經試過了。這不適用於'opencv 3.3.0'。它給編譯錯誤。 – Darshana

+0

呵呵,我用'opencv 2.4.13'和'SURF','SurfFeatureDetector','SurfDescriptorExtractor'是一樣的。 –