Ask Your Question

Revision history [back]

SVM derived class

I am trying to create a derived class from the Opencv3.0 SVM in the following way and I get an error. Can anyone suggest a solution for this? Thanks in advance.

class MyClass: public SVM

{

}

int main(void) { MyClass *mysvm = new MyClass; }

This defnition is generating the following error while compilation:-

||In function 'int main()':| error: invalid new-expression of abstract class type 'MyClass'| note: because the following virtual functions are pure within 'MyClass':| |302|note: virtual int cv::ml::StatModel::getVarCount() const| |307|note: virtual bool cv::ml::StatModel::isTrained() const| |309|note: virtual bool cv::ml::StatModel::isClassifier() const| |349|note: virtual float cv::ml::StatModel::predict(cv::InputArray, cv::OutputArray, int) const| |493|note: virtual int cv::ml::SVM::getType() const| |495|note: virtual void cv::ml::SVM::setType(int)| |500|note: virtual double cv::ml::SVM::getGamma() const| |502|note: virtual void cv::ml::SVM::setGamma(double)| |507|note: virtual double cv::ml::SVM::getCoef0() const| |509|note: virtual void cv::ml::SVM::setCoef0(double)| |514|note: virtual double cv::ml::SVM::getDegree() const| |516|note: virtual void cv::ml::SVM::setDegree(double)| |521|note: virtual double cv::ml::SVM::getC() const| |523|note: virtual void cv::ml::SVM::setC(double)| |528|note: virtual double cv::ml::SVM::getNu() const| |530|note: virtual void cv::ml::SVM::setNu(double)| |535|note: virtual double cv::ml::SVM::getP() const| |537|note: virtual void cv::ml::SVM::setP(double)| |545|note: virtual cv::Mat cv::ml::SVM::getClassWeights() const| |547|note: virtual void cv::ml::SVM::setClassWeights(const cv::Mat&)| |554|note: virtual cv::TermCriteria cv::ml::SVM::getTermCriteria() const| |556|note: virtual void cv::ml::SVM::setTermCriteria(const cv::TermCriteria&)| |560|note: virtual int cv::ml::SVM::getKernelType() const| |564|note: virtual void cv::ml::SVM::setKernel(int)| |568|note: virtual void cv::ml::SVM::setCustomKernel(const cv::Ptr<cv::ml::svm::kernel>&)| |665|note: virtual bool cv::ml::SVM::trainAuto(const cv::Ptr<cv::ml::traindata>&, int, cv::ml::ParamGrid, cv::ml::ParamGrid, cv::ml::ParamGrid, cv::ml::ParamGrid, cv::ml::ParamGrid, cv::ml::ParamGrid, bool)| |679|note: virtual cv::Mat cv::ml::SVM::getSupportVectors() const| |696|note: virtual double cv::ml::SVM::getDecisionFunction(int, cv::OutputArray, cv::OutputArray) const| ||=== Build failed: 1 error(s), 18 warning(s) (0 minute(s), 2 second(s)) ===|

click to hide/show revision 2
No.2 Revision

updated 2015-10-03 04:04:19 -0600

berak gravatar image

SVM derived class

I am trying to create a derived class from the Opencv3.0 SVM in the following way and I get an error. Can anyone suggest a solution for this? Thanks in advance.

class MyClass: public SVM

{

}

SVM { ----- } int main(void) { MyClass *mysvm = new MyClass; }

}

This defnition is generating the following error while compilation:-

||In function 'int main()':|
error: invalid new-expression of abstract class type 'MyClass'|
note:   because the following virtual functions are pure within 'MyClass':|
 |302|note:     virtual int cv::ml::StatModel::getVarCount() const|
 |307|note:     virtual bool cv::ml::StatModel::isTrained() const|
 |309|note:     virtual bool cv::ml::StatModel::isClassifier() const|
 |349|note:     virtual float cv::ml::StatModel::predict(cv::InputArray, cv::OutputArray, int) const|
 |493|note:     virtual int cv::ml::SVM::getType() const|
 |495|note:     virtual void cv::ml::SVM::setType(int)|
 |500|note:     virtual double cv::ml::SVM::getGamma() const|
 |502|note:     virtual void cv::ml::SVM::setGamma(double)|
 |507|note:     virtual double cv::ml::SVM::getCoef0() const|
 |509|note:     virtual void cv::ml::SVM::setCoef0(double)|
 |514|note:     virtual double cv::ml::SVM::getDegree() const|
 |516|note:     virtual void cv::ml::SVM::setDegree(double)|
 |521|note:     virtual double cv::ml::SVM::getC() const|
 |523|note:     virtual void cv::ml::SVM::setC(double)|
 |528|note:     virtual double cv::ml::SVM::getNu() const|
 |530|note:     virtual void cv::ml::SVM::setNu(double)|
 |535|note:     virtual double cv::ml::SVM::getP() const|
 |537|note:     virtual void cv::ml::SVM::setP(double)|
 |545|note:     virtual cv::Mat cv::ml::SVM::getClassWeights() const|
 |547|note:     virtual void cv::ml::SVM::setClassWeights(const cv::Mat&)|
 |554|note:     virtual cv::TermCriteria cv::ml::SVM::getTermCriteria() const|
 |556|note:     virtual void cv::ml::SVM::setTermCriteria(const cv::TermCriteria&)|
 |560|note:     virtual int cv::ml::SVM::getKernelType() const|
 |564|note:     virtual void cv::ml::SVM::setKernel(int)|
 |568|note:     virtual void cv::ml::SVM::setCustomKernel(const cv::Ptr<cv::ml::svm::kernel>&)|
cv::Ptr<cv::ml::SVM::Kernel>&)|
 |665|note:     virtual bool cv::ml::SVM::trainAuto(const cv::Ptr<cv::ml::traindata>&, cv::Ptr<cv::ml::TrainData>&, int, cv::ml::ParamGrid, cv::ml::ParamGrid, cv::ml::ParamGrid, cv::ml::ParamGrid, cv::ml::ParamGrid, cv::ml::ParamGrid, bool)|
 |679|note:     virtual cv::Mat cv::ml::SVM::getSupportVectors() const|
 |696|note:     virtual double cv::ml::SVM::getDecisionFunction(int, cv::OutputArray, cv::OutputArray) const|
||=== Build failed: 1 error(s), 18 warning(s) (0 minute(s), 2 second(s)) ===|

===|