SVM copy constructor is private
I am using a SVM classifier for validating my detections. But when I have tried to copy the SVM it says the the copy constructor is private.
/usr/local/include/opencv2/ml/ml.hpp:553:5: error: ‘CvSVM::CvSVM(const CvSVM&)’ is private
If I change to m_svm = svmIn
it says that operator =
is also private.
/usr/local/include/opencv2/ml/ml.hpp:554:12: error: ‘CvSVM& CvSVM::operator=(const CvSVM&)’ is private
Now I am wondering how to copy my classifier? Shall I construct it every time?
Have a look at this
Ok, but my question is how to copy SVM? No way, I cannot, that is the answer?
Not with a copy or assignment operator, it is this way because of the underlying data (pointers and such are not managed) so you have to do that yourself or disable the copy and assignment operator, that's why the fix is there to disable them. Maybe the read/write member functions can be of any use for you...
it is not allowed to copy or assign it. (that's the purpose of a private copy constructor)
also, please use the c++ SVM class instead.
@berak: I was using
cv::SVM classifier(trainingData, classes, cv::Mat(), cv::Mat(), svmParams);
an I am using OpenCV 2.4.9, so I thin inside the class theCvSVM
is usedbetter, but obviously still the same problem. can you avoid to copy it ?
SVM a;
SVM b=a; // illegal.
SVM & b = a; // legal;
Ptr<SVM> a = new SVM;
Ptr<SVM> b = a; // legal
Yes, I have managed to find a way of avoiding the copy.