Hello, I trained an SVM model and save it in xml file, everythink look good. but when I load the model I print the getvar vaule its equal to 0? The model file looks fine to me?
<?xml version="1.0"?>
<opencv_storage>
<opencv_ml_svm>
<format>3</format>
<svmType>C_SVC</svmType>
<kernel>
<type>LINEAR</type></kernel>
<C>1.0000000000000001e-01</C>
<term_criteria><epsilon>1.1920928955078125e-07</epsilon>
<iterations>1000</iterations></term_criteria>
<var_count>4096</var_count>
<class_count>2</class_count>
<class_labels type_id="opencv-matrix">
<rows>2</rows>
<cols>1</cols>
<dt>i</dt>
<data>
1 2</data></class_labels>
<sv_total>1</sv_total>
<support_vectors>
<_>
-6.66133815e-15 -4.88498131e-15 -3.33066907e-15 -3.33066907e-15 0.
This is a part of the train code :
Ptr<ml::SVM> Model = ml::SVM::create();
Ptr<ml::TrainData> TrainData = ml::TrainData::create(Data, ml::ROW_SAMPLE, Label);
Model->setType(SVM);
Model->setKernel(Kernel);
Model->trainAuto(TrainData,5);
Model->save((*path));
Test part in other project :
Ptr<ml::SVM> classifier = ml::SVM::create();
classifier->load(*modelPath);
Mat features = (*featuresSptr)[i];
features.convertTo(features, CV_32F);
float label = classifier->predict(features);
error :
OpenCV Error: Assertion failed (samples.cols == var_count && samples.type() == CV_32F) in predict