Quantcast
Channel: OpenCV Q&A Forum - Latest question feed
Viewing all articles
Browse latest Browse all 19555

OpenCV 3.1 (C++) - SVM.load() does not set var_count correctly

$
0
0
Okay, I have some training data with 35 variables, I trained an SVM classifier and saved it using: svm->save("trained-svm.xml") In another application, I was trying to load the classifier using the XML file saved previously, and I encountered an Assertion Failure when I tried to call predict() on a piece of new input data: OpenCV Error: Assertion failed (samples.cols == var_count && samples.type() == CV_32F) in cv::ml::SVMImpl::predict, file E:\Downloads\opencv\sources\modules\ml\src\svm.cpp, line 1930 I double checked that I have loaded my data as CV_32F type, which means that the assertion failed at samples.cols == var_count. And I double checked that I did have the right number of columns (35) in my test data. So I tried to print out the var_count as follows: svm->load("trained-svm.xml"); cout << svm->getVarCount() << endl; The result is that getVarCount() reports value of -842150451, which is clearly wrong. Since my XML does mention var_count as 35. Apparently load() doesn't update this value, causing the assertion. 3C_SVCLINEAR1.1.1920928955078125e-071000 **35**661
i
1 2 3 4 5 6
15 (snipped away rest of XML) Any solutions to this?

Viewing all articles
Browse latest Browse all 19555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>