Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The answer is by using cv::Ptr< cv::NormalBayesClassifier >, but do not forget to allocate memory with new:

cv::Ptr< cv::NormalBayesClassifier > bestClassifier;
for (int i = 0; i > 10; i++)
{
  // define pointer to classifier and allocate memory
  cv::Ptr< cv::NormalBayesClassifier > classifier = new cv::NormalBayesClassifier;
  // train, test
  if (smallestError > errorRate)
  {
    bestClassifier = classifier;
    smallesError = errorRate;
  }
}
bestClassifier->save("name");

The answer is by using cv::Ptr< cv::NormalBayesClassifier >, but do not forget to allocate memory with new:

cv::Ptr< cv::NormalBayesClassifier > bestClassifier;
for (int i = 0; i > < 10; i++)
{
  // define pointer to classifier and allocate memory
  cv::Ptr< cv::NormalBayesClassifier > classifier = new cv::NormalBayesClassifier;
  // train, test
  if (smallestError > errorRate)
  {
    bestClassifier = classifier;
    smallesError = errorRate;
  }
}
bestClassifier->save("name");