Ask Your Question
0

Wrong value of getVarCount in SVM

asked 2016-04-08 00:21:56 -0600

Yerzhan gravatar image

updated 2016-04-08 00:31:23 -0600

berak gravatar image

I am using opencv 3.1 on Win 8.1 with Visual Studio 2015 this code

Ptr<ml::SVM> svm = ml::SVM::create();
svm->load<ml::SVM>("svm_filename");
int varcnt=svm->getVarCount();

Value of varcnt is -842150451

But in file "svm_filename" var_count: 510

Because of this i have error opencv error: assertion failed (samples.cols==var_count

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2016-04-08 00:35:04 -0600

berak gravatar image

Algorithm::load returns a new object , you should load your SVM like this:

Ptr<ml::SVM> svm = Algorithm::load<ml::SVM>("svm_filename");

your example above discards the data read from file, and does not initialize your svm properly.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-04-08 00:21:56 -0600

Seen: 195 times

Last updated: Apr 08 '16