I'm not an expert in machine learning and I don't understand the error that my code throws.
So I train a svm with 15 classes. everything is fine.
// Set up SVM's parameters
Ptr<SVM> svm = SVM::create();
svm->setType(SVM::C_SVC);
svm->setKernel(SVM::POLY);
svm->setC(100);
svm->setTermCriteria(TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 100, 1e-6));
svm->setDegree(1);
// Train the SVM with given parameters
Ptr<TrainData> td = TrainData::create(training_mat, ROW_SAMPLE, labelsMat);
svm->train(td);
svm->save("output/xml/svm_filename.xml");
I implement the HOG descriptor like that HOGDescriptor hog(Scalar(16,16), Scalar(8,8), Scalar(4,4), Scalar(4,4), 9);
The Problem is that the program crashed when I call this method the setSVMDetector:
Ptr<SVM> svm = SVM::create();
svm = svm->load("output/xml/svm_filename.xml");
hog.setSVMDetector(svm->getSupportVectors());
the error is
OpenCV Error: Assertion failed (d == 2 && (sizes[0] == 1 || sizes[1] == 1 || sizes[0]*sizes[1] == 0)) in create, file /home/leo/extra/opencv-3.2.0/modules/core/src/matrix.cpp, line 2410
the same code is working perfectly when I only train the svm with 2 classes.
I don't know what this error message means, I've already looked around, and I found nothing.
Can someone please help me?