title: OpenCV SVM throwing exception on train, "Bad argument (There is only a single class)"
body: <p>I'm stuck on this one.</p>
  
  <p>I am trying to do some object classification through OpenCV feature 2d framework, but am running into troubles on training my SVM. </p>
  
  <p>I am able to extract vocabularies and cluster them using BowKMeansTrainer, but after I extract features from training data to add to the trainer and run SVM.train method, I get the following exception.</p>
  
  <pre><code>OpenCV Error: Bad argument (There is only a single class) in     cvPreprocessCategoricalResponses, file /home/tbu/prog/OpenCV-2.4.2/modules/ml/src    /inner_functions.cpp, line 729
  terminate called after throwing an instance of 'cv::Exception'
   what():  /home/tbuchy/prog/OpenCV-2.4.2/modules/ml/src/inner_functions.cpp:729: error:     (-5) There is only a single class in function cvPreprocessCategoricalResponses
  </code></pre>
  
  <p>I have tried modifying dictionary size, using different trainers, ensuring my matrix types are correct (to the best of my ability, still new to opencv). </p>
  
  <p>Has any seen this error or have any insight on how to fix it?</p>
  
  <p>My code looks like this:</p>
  
  <pre><code>trainingPaths = getFilePaths();
  extractTrainingVocab(trainingPaths);
  cout&lt;&lt;"Clustering..."&lt;&lt;endl;
  Mat dictionary = bowTrainer.cluster();
  bowDE.setVocabulary(dictionary);
  
  
  Mat trainingData(0, dictionarySize, CV_32FC1);
  Mat labels(0, 1, CV_32FC1);
  extractBOWDescriptor(trainingPaths, trainingData, labels);
  
  
  //making the classifier
  CvSVM classifier;
  CvSVMParams params;
  params.svm_type    = CvSVM::C_SVC;
  params.kernel_type = CvSVM::LINEAR;
  params.term_crit   = cvTermCriteria(CV_TERMCRIT_ITER, 100, 1e-6);
  
  classifier.train(trainingData, labels, Mat(), Mat(), params);
  </code></pre>