Ask Your Question
1

cv::ml not compiling in opencv 3.0

asked 2015-08-06 15:57:27 -0600

tpacker gravatar image

I downloaded, built, and installed OpenCV 3.0.0 on Ubuntu 14.10, 64-bit. I have a C++ project in NetBeans that compiles, links, and runs. I am now trying to follow the tutorial here: http://docs.opencv.org/3.0-beta/doc/t...

I have the "#includes" and the "using namespaces" as specified in the tutorial, and NetBeans and g++ both seem able to find these things. But when I add some ml-specific code such as "SVM::Params params;", I get compiler errors, below.

g++ -std=c++11   -c -g -I/usr/local/include -I/usr/include/libxml2/ -I/usr/local/include/opencv2 -MMD -MP -MF "build/Debug/GNU-Linux-x86/my_file.o.d" -o build/Debug/GNU-Linux-x86/my_file.o my_file.cpp
my_file.cpp: In function ‘void mynamespace::myFunction()’:
my_file.cpp:153:3: error: ‘Params’ is not a member of ‘cv::ml::SVM’
   SVM::Params params;
   ^

What might I be missing?

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
2

answered 2015-08-06 16:33:32 -0600

LorenaGdL gravatar image

updated 2015-08-06 17:20:22 -0600

There are no more SVM::Params in OpenCV 3.0.0. The structure of the ml module is now different (look here). You will need to use the new setters and getters to configure your parameters.

For example:

//In OpenCV 2.4.x
SVM::Params params;
params.C = 0.01;

//In OpenCV 3.0.0
Ptr<SVM> my_svm = SVM::create();
my_svm->setC(0.01);
edit flag offensive delete link more

Comments

Thanks. That is a step in the right direction. When I add your second pair of lines, I get the following error:

sploit_page_classifier.cpp:152:28: error: cannot allocate an object of abstract type ‘cv::ml::SVM’
SVM my_svm = SVM::create();
                        ^
tpacker gravatar imagetpacker ( 2015-08-06 17:03:45 -0600 )edit

Sorry, I had a typo

LorenaGdL gravatar imageLorenaGdL ( 2015-08-06 17:20:47 -0600 )edit

Thanks. That works. g++ now compiles and it runs. NetBeans still says "Unable to resolve identifier SVM." for some reason, but that may be a NetBeans-specific error.

By the way, was I looking at the wrong documentation/tutorial, or should that one be updated as you illustrate above?

tpacker gravatar imagetpacker ( 2015-08-06 17:42:52 -0600 )edit

You can found the new tutorial here.

LorenaGdL gravatar imageLorenaGdL ( 2015-08-06 18:01:01 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-08-06 15:57:27 -0600

Seen: 3,502 times

Last updated: Aug 06 '15