2015-01-21 9 views
0

이미지에서 KeyPoints를 찾을 수있는 클래스를 만들려고합니다. 그러나, 나는 우스꽝스러운 오류가 발생합니다. 해결 방법을 찾을 수 없습니다.OpenCV FeatureDetector가 초기화되지 않았습니다.

문제는

this->detector 

가 제로 지금, 그래서 제대로 초기화되지 어떤 이유에서입니다. Google에서 검색했지만 아무 것도 찾지 못했습니다. 내가 cmake를 사용

// Input: The new image and the old image. Find Keypoints and extract the descriptors. 
void FindKeyPoints::detectKeypoints(cv::Mat& imgNew, 
     cv::Mat& imgOld) { 
    if (this->detector == 0){ 
     cout<<"Hej"<<endl; 
    } 
// this->detector->detect(imgNew, keyPointsNew); 
// this->detector->detect(imgOld, keyPointsOld); 
} 

과 (일부 :

/* 
* FindKeyPoints.h 
* 
* Created on: Jan 21, 2015 
*  Author: erikbylow 
*/ 

#ifndef FINDKEYPOINTS_H_ 
#define FINDKEYPOINTS_H_ 

#include <vector> 
#include <opencv2/nonfree/features2d.hpp> 
#include <opencv2/features2d/features2d.hpp> 
#include <opencv/cv.h> 
#include <opencv/highgui.h> 
#include <opencv/cxcore.h> 
using namespace std; 

class FindKeyPoints { 

private: 
    // Create vector of KeyPoints to store the detected keypoint in 
    vector<cv::KeyPoint> keyPointsOld; 
    vector<cv::KeyPoint> keyPointsNew; 
    // Threshold for similarity 
    const int THRESHOLD = 10; 

    // Instance(?) DescriptionExtractor and descriptor 
    cv::Ptr<cv::DescriptorExtractor> descriptionExtractor; 
    cv::Ptr<cv::FeatureDetector> detector; 

public: 
    FindKeyPoints(const string &METHOD); 
    virtual ~FindKeyPoints(); 
    void detectKeypoints(cv::Mat& imgNew, cv::Mat& imgOld); 
}; 

#endif /* FINDKEYPOINTS_H_ */ 

을 다음과 생성자는

FindKeyPoints::FindKeyPoints(const string &METHOD) { 
    cout<<METHOD<<endl; 
    cv::initModule_features2d(); 
    this->detector = cv::FeatureDetector::create("SURF"); 
    //this->descriptionExtractor = cv::DescriptorExtractor::create(METHOD); 
} 

으로 모양과 같은 기능이 나는 외모를 사용으로

내 headerfile 보인다) 내 CMakeLists.txt는 다음과 같습니다 :

그것은

${OpenCV_LIBS} 

이 libopencv_nonfree.so 포함되지 않습니다 될 수 있을까?

안부

+0

. 프로젝트에 필요한 .libs 파일을 모두 포함 했습니까? – pwwpche

+0

질문에 내 CMakeLists.txt를 넣으십시오. –

+0

"우스운"오류가 무엇입니까? cv :: FeatureDetector :: detect (cv :: Mat const & std :: vector >)에서 전체 스택 추적 – ha9u63ar

답변

0

나는 오류가 난 단지

opencv2/nonfree/features2d.hpp 

등을 포함했다고 의심되지도

코드 아무 문제가 없습니다
opencv2/nonfree/nonfree.hpp. 
관련 문제