Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to use my HOG matrix in the SVM classifier?

I want to use the normalised HOG matrix which contains the features of my image. How to take the HoG matrix to use it in the SVM classifier? Does anyone has any idea how to do it?

Here is my HOG matrix:

FileStorage f("Normalised_HOG.xml", FileStorage::READ);

Here is my data labelling :

//assign label
        Mat labels(num_files, 1, CV_32FC1);

        float trainingData;
        cv::Mat trainDataMat(num_files, DESCRIPT, CV_32FC1, trainingData);

Here is my SVM Parameters

//set up SVM Parameters
    Ptr<cv::ml::SVM> svm = cv::ml::SVM::create();
    svm->setType(SVM::C_SVC);
    svm->setKernel(SVM::LINEAR);
    svm->setTermCriteria(TermCriteria(TermCriteria::MAX_ITER, 100, 1e-6));
    // Train the SVM
    svm->train(trainDataMat, ROW_SAMPLE, labels);
    cout << "Saving Trained SVM xml ..." << endl;
    //svm->write(FileStorage("test.xml", FileStorage::WRITE));
    svm->save("SVM.xml");