Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

error: ‘create’ is not a member of ‘cv::FeatureDetector {aka cv::Feature2D}’ Ptr<featuredetector> detector = FeatureDetector::create("SURF") and some compiling errors for OpenCV sample code

I am trying to compile the sample demo: here

I have been slowly repairing different compiling errors. I have added includes for:

#include <opencv2/xfeatures2d/nonfree.hpp>
#include <opencv2/features2d/features2d.hpp>

I have also written:

initModule_nonfree();

At the beginning of the main method. When I compile with: g++ -ggdb -I/usr/local/include/opencv -I/usr/local/include -lopencv_features2d -lopencv_highgui -lopencv_imgproc -lopencv_nonfree -lopencv_core -lopencv_flann main.cpp -o main

I get the errors:

main.cpp:19:38: error: ‘create’ is not a member of ‘cv::DescriptorExtractor {aka cv::Feature2D}’ Ptr<descriptorextractor> extractor = DescriptorExtractor::create("SURF"); ^

main.cpp:20:33: error: ‘create’ is not a member of ‘cv::FeatureDetector {aka cv::Feature2D}’ Ptr<featuredetector> detector = FeatureDetector::create("SURF"); ^

main.cpp: In function ‘int main(int, char**)’: main.cpp:113:21: error: ‘initModule_nonfree’ was not declared in this scope initModule_nonfree(); ^

main.cpp:130:2: error: ‘NormalBayesClassifier’ was not declared in this scope NormalBayesClassifier classifier;

I am including the nonfree libraries. Is there something else I need to do to compile this properly?