Ask Your Question
0

cv::KNearest missing in 3.0.0, cv::ml::KNearest abstract?

asked 2014-11-07 16:35:37 -0500

wolfram79 gravatar image

updated 2014-11-07 16:38:48 -0500

Hi,

I have a perfectly working program written in c++ under Mac OS 10.9 (LLVM) with QT5 and OpenCV that i pulled some weeks ago from the development branch. It uses cv::KNearest.

I'm trying to compile this application under Windows using OpenCV 3.0.0 Alpha, QT5 latest version, Visual Studio '13 but don't succeed.

I get

cv::KNearest : Is not a member of 'cv' (?)

Looking into the <ml.hpp> class, I figured out to try to use cv::ml::KNearest instead, but now I get

C2259 cv::ml::KNearest : cannot instantiate abstract class

Can somebody help me with this? Has there been a recent change in the KNearest / ML code, ...?

Sincerely,

Wolfram

edit retag flag offensive close merge delete

Comments

Thanks a lot for the quick reply. The method

CvKNearest::get_sample_count ( Manual : Returns the total number of train samples. C++: int CvKNearest::get_sample_count() const )

seems to be missing as well... what happend to it / how to I get the train sample count now?

Thanks again

wolfram79 gravatar imagewolfram79 ( 2014-11-11 08:15:41 -0500 )edit

Thanks a lot for the quick reply. The method

CvKNearest::get_sample_count ( Manual : Returns the total number of train samples. C++: int CvKNearest::get_sample_count() const )

seems to be missing as well... what happend to it / how to I get the train sample count now?

Thanks again

wolfram79 gravatar imagewolfram79 ( 2014-11-11 08:16:04 -0500 )edit

Thanks a lot for the quick reply. The method

CvKNearest::get_sample_count ( Manual : Returns the total number of train samples. C++: int CvKNearest::get_sample_count() const )

seems to be missing as well... what happend to it / how to I get the train sample count now?

Thanks again

wolfram79 gravatar imagewolfram79 ( 2014-11-11 08:18:01 -0500 )edit

Thanks a lot for the quick reply. The method

CvKNearest::get_sample_count ( Manual : Returns the total number of train samples. C++: int CvKNearest::get_sample_count() const )

seems to be missing as well... what happend to it / how to I get the train sample count now?

Thanks again

wolfram79 gravatar imagewolfram79 ( 2014-11-11 08:18:18 -0500 )edit

2 answers

Sort by ยป oldest newest most voted
2

answered 2014-11-08 00:17:01 -0500

berak gravatar image

the ml module in 3.0 got some refactoring lately.

you can no more create an instance 'on the stack' like KNearest knn;

instead, you will have to use :

 Ptr<ml::KNearest> knn = ml::KNearest::create();
 knn->train(...);
 knn->predict(...);

(btw, same for SVM, EM, etc.)

edit flag offensive delete link more

Comments

Thanks a lot for the quick reply. The method

CvKNearest::get_sample_count ( Manual : Returns the total number of train samples. C++: int CvKNearest::get_sample_count() const )

seems to be missing as well... what happend to it / how to I get the train sample count now?

Thanks again

wolfram79 gravatar imagewolfram79 ( 2014-11-11 07:41:33 -0500 )edit
0

answered 2015-01-18 15:12:58 -0500

pmdev gravatar image

I've done like you, but I've got still errors in create line. What should be the parameter of create function?

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

Stats

Asked: 2014-11-07 16:35:37 -0500

Seen: 2,918 times

Last updated: Nov 08 '14