2017-10-16 29 views
-1

Ich verwende opencv 3.3.0Nach der Zugabe von SurfFeatureDetector, Programmfehler geben

meinen Code

#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; 
} 

Ich bin neu in C++ und opencv. Der Code funktioniert gut ohne Surfpart.

Fehler

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

Ich habe auch mit Ptr<SURF> detector = SURF::create(400); versucht.

UPDATE

Ich konnte keine Lösung für diese herauszufinden. Vielleicht ein Setup-Problem oder ein Bibliotheksproblem. Also gehe ich einfach zu opencv 2.4.13 und jetzt funktioniert alles gut. Ich musste den obigen Code ändern, um mit v2.4.13 zu arbeiten.

+0

Wenn Sie unten abstimmen, erwähnen Sie bitte einen Grund. – Darshana

Antwort

0

Sie haben keinen Parameter für SurfFeatureDetector eingestellt. Ich denke, du solltest das stattdessen versuchen:

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

Ich habe das schon probiert. Dies funktioniert nicht mit 'opencv 3.3.0'. Es gibt Kompilierungsfehler. – Darshana

+0

Oh, ich benutze 'opencv 2.4.13' und' SURF', 'SurfFeatureDetector',' SurfDescriptorExtractor' ist das selbe. –

Verwandte Themen