Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to copy NormalBayesClassifier?

I am training and testing more classifiers and I want to save just the best of them. I have tried to use an if and =

// for each train/eval
if (smallestError > errorRate)
{
  best_Classifier = classifier;
}
// end for
best_Classifier.save("name");

but it seems that it gives me some null pointer error:

OpenCV Error: Null pointer (Null pointer to the written object) in cvWrite, file /home/stefan/git_repos/opencv/modules/core/src/persistence.cpp, line 5011
terminate called after throwing an instance of 'cv::Exception'
  what():  /home/stefan/git_repos/opencv/modules/core/src/persistence.cpp:5011: error: (-27) Null pointer to the written object in function cvWrite

How to copy NormalBayesClassifier?

I am training and testing more classifiers and I want to save just the best of them. I have tried to use an if and =

// for each train/eval
if (smallestError > errorRate)
{
  best_Classifier = classifier;
}
// end for
best_Classifier.save("name");

but it seems that it gives me some null pointer error:

OpenCV Error: Null pointer (Null pointer to the written object) in cvWrite, file /home/stefan/git_repos/opencv/modules/core/src/persistence.cpp, /home/me/opencv/modules/core/src/persistence.cpp, line 5011
terminate called after throwing an instance of 'cv::Exception'
  what():  /home/stefan/git_repos/opencv/modules/core/src/persistence.cpp:5011: /home/me/opencv/modules/core/src/persistence.cpp:5011: error: (-27) Null pointer to the written object in function cvWrite

Can you suggest me some other way if this is not possible?

How to copy NormalBayesClassifier?

I am training and testing more classifiers and I want to save just the best of them. I have tried to use an if and =

// for each train/eval
if (smallestError > errorRate)
{
  best_Classifier = classifier;
}
// end for
best_Classifier.save("name");

but it seems that it gives me some null pointer error:

OpenCV Error: Null pointer (Null pointer to the written object) in cvWrite, file /home/me/opencv/modules/core/src/persistence.cpp, line 5011
terminate called after throwing an instance of 'cv::Exception'
  what():  /home/me/opencv/modules/core/src/persistence.cpp:5011: error: (-27) Null pointer to the written object in function cvWrite

Can you suggest me some other way if this is not possible?


EDIT:

I have also tried using Ptr, but it still does not work:

cv::Ptr< cv::NormalBayesClassifier > bestClassifier;
// for loop where train and evaluate the classifier cv::NormalBayesClassifier classifier;
if (smallestError > errorRate)
{
  best_Classifier = &classifier;
  smallesError = errorRate;
}

// end loop

best_Classifier->save("name");

And it gives me the following error:

OpenCV Error: The function/feature is not implemented () in CvStatModel::write, file /home/stefan/git_repos/opencv/modules/ml/src/inner_functions.cpp, line 114
terminate called after throwing an instance of 'cv::Exception'
  what():  /home/stefan/git_repos/opencv/modules/ml/src/inner_functions.cpp:114: error: (-213)  in function CvStatModel::write

How to copy NormalBayesClassifier?

I am training and testing more classifiers and I want to save just the best of them. I have tried to use an if and =

// for each train/eval
if (smallestError > errorRate)
{
  best_Classifier = classifier;
}
// end for
best_Classifier.save("name");

but it seems that it gives me some null pointer error:

OpenCV Error: Null pointer (Null pointer to the written object) in cvWrite, file /home/me/opencv/modules/core/src/persistence.cpp, line 5011
terminate called after throwing an instance of 'cv::Exception'
  what():  /home/me/opencv/modules/core/src/persistence.cpp:5011: error: (-27) Null pointer to the written object in function cvWrite

Can you suggest me some other way if this is not possible?


EDIT:

I have also tried using Ptr, but it still does not work:

cv::Ptr< cv::NormalBayesClassifier > bestClassifier;
// for loop where train and evaluate the classifier cv::NormalBayesClassifier classifier;
if (smallestError > errorRate)
{
  best_Classifier = &classifier;
  smallesError = errorRate;
}

// end loop

best_Classifier->save("name");

And it gives me the following error:

OpenCV Error: The function/feature is not implemented () in CvStatModel::write, file /home/stefan/git_repos/opencv/modules/ml/src/inner_functions.cpp, /home/me/opencv/modules/ml/src/inner_functions.cpp, line 114
terminate called after throwing an instance of 'cv::Exception'
  what():  /home/stefan/git_repos/opencv/modules/ml/src/inner_functions.cpp:114: /home/me/opencv/modules/ml/src/inner_functions.cpp:114: error: (-213)  in function CvStatModel::write
click to hide/show revision 5
retagged

updated 2014-06-25 12:02:19 -0600

berak gravatar image

How to copy NormalBayesClassifier?

I am training and testing more classifiers and I want to save just the best of them. I have tried to use an if and =

// for each train/eval
if (smallestError > errorRate)
{
  best_Classifier = classifier;
}
// end for
best_Classifier.save("name");

but it seems that it gives me some null pointer error:

OpenCV Error: Null pointer (Null pointer to the written object) in cvWrite, file /home/me/opencv/modules/core/src/persistence.cpp, line 5011
terminate called after throwing an instance of 'cv::Exception'
  what():  /home/me/opencv/modules/core/src/persistence.cpp:5011: error: (-27) Null pointer to the written object in function cvWrite

Can you suggest me some other way if this is not possible?


EDIT:

I have also tried using Ptr, but it still does not work:

cv::Ptr< cv::NormalBayesClassifier > bestClassifier;
// for loop where train and evaluate the classifier cv::NormalBayesClassifier classifier;
if (smallestError > errorRate)
{
  best_Classifier = &classifier;
  smallesError = errorRate;
}

// end loop

best_Classifier->save("name");

And it gives me the following error:

OpenCV Error: The function/feature is not implemented () in CvStatModel::write, file /home/me/opencv/modules/ml/src/inner_functions.cpp, line 114
terminate called after throwing an instance of 'cv::Exception'
  what():  /home/me/opencv/modules/ml/src/inner_functions.cpp:114: error: (-213)  in function CvStatModel::write