Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to SVM predict more than one sample?

I want to classify more than one single image with a SVM trained before. I know that there is the

void predict( cv::InputArray samples, cv::OutputArray results )

but I get the following error

OpenCV Error: Incorrect size of input array (Input sample must be 1-dimensional vector) in cvPreparePredictData, file /home/stefan/git_repos/opencv/modules/ml/src/inner_functions.cpp, line 1107
terminate called after throwing an instance of 'cv::Exception'
  what():  /home/stefan/git_repos/opencv/modules/ml/src/inner_functions.cpp:1107: error: (-201) Input sample must be 1-dimensional vector in function cvPreparePredictData

if I have :

cv::Mat testPredictions;
Mat samples = testDLN.getBOWDescritprs(); // samples is a 90x150 Mat
m_classifier->predict(samples, &testPredictions);

How shall I classify the set of images? Shall I use a for loop instead?