Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

opencv error: assertion failed (samples.cols == var_count && samples.type() == 5) in cv::ml:: etc.

I created a xml file by using svm . In my test program i have loaded that xml file and i use svm predict, but it showing the error. how can i correct this ?

int main(){
HOGDescriptor hog;
vector<float> featureVector;
Ptr<ml::SVM> svm = ml::SVM::create();

Mat testdata, feature;


Mat img = imread("C:/Users/Sam/Desktop/Test/1.jpg");


    hog.compute(img, featureVector, Size(32, 32), Size(0, 0));


    feature = Mat(featureVector).reshape(1, 1);
    testdata.push_back(feature);


    svm->load("Features.xml");

    svm->predict(testdata);

}

image description

opencv error: assertion failed (samples.cols == var_count && samples.type() == 5) in cv::ml:: etc.

I created a xml file by using svm . In my test program i have loaded that xml file and i use svm predict, but it showing the error. how can i correct this ?

int main(){
HOGDescriptor hog;
vector<float> featureVector;
Ptr<ml::SVM> svm = ml::SVM::create();

Mat testdata, feature;


Mat img = imread("C:/Users/Sam/Desktop/Test/1.jpg");


    hog.compute(img, featureVector, Size(32, 32), Size(0, 0));


    feature = Mat(featureVector).reshape(1, 1);
    testdata.push_back(feature);


    svm->load("Features.xml");

    svm->predict(testdata);

}

image description