Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

please do not try to inherit from ml::SVM, but layer(encapsulate) it.

the long story is: while your class can inherit the interface, this way you can't inherit the hidden implementation

please do not try to inherit from ml::SVM, but layer(encapsulate) it.

the long story is: while your class can inherit the interface, this way you can't inherit the hidden implementation

also, please avoid using new , and raw pointers in general. either use plain RAII and auto storage, like:

MyClass mysvm;

or use a smartpointer, like:

 cv::Ptr<MyClass> mysvm = cv::makePtr<MyClass>();

please do not try to inherit from ml::SVM, but layer(encapsulate) it.

the long story is: while your class can inherit the interface, this way you can't inherit the hidden implementation

also, please avoid using new , and raw pointers in general. either use plain RAII and auto storage, like:

MyClass mysvm;
mysvm.setC(1);

or use a smartpointer, like:

 cv::Ptr<MyClass> mysvm = cv::makePtr<MyClass>();
mysvm->setGamma(0.2);

please do not try to inherit from ml::SVM, but layer(encapsulate) it.

the long story is: while your class can inherit the interface, this way you can't inherit the hidden implementation

also, please avoid using new , and raw pointers in general. either use plain RAII and auto storage, like:

MyClass mysvm;
mysvm.setC(1);
mysvm.doSomething();

or use a smartpointer, like:

cv::Ptr<MyClass> mysvm = cv::makePtr<MyClass>();
mysvm->setGamma(0.2);
mysvm->doSomething();

please do not try to inherit from ml::SVM, but layer(encapsulate) it.

the long story is: while your class can inherit the interface, this way you can't inherit the hidden implementation

so, try like:

class MySVM
{
    Ptr<ml::SVM> svm;
public:
    MySVM() : svm(ml::SVM::create()) {}

    void doSomehing()
    {
         // use layered, private implementation
         svm->someMethod();
    }
};

also, please avoid using new , and raw pointers in general. either use plain RAII and auto storage, like:

MyClass mysvm;
mysvm.doSomething();

or use a smartpointer, like:

cv::Ptr<MyClass> mysvm = cv::makePtr<MyClass>();
mysvm->doSomething();

please do not try to inherit from ml::SVM, but layer(encapsulate) it.

the long story is: while your class can inherit the interface, this way you can't inherit the hidden implementationimplementation, meaning, that you will have to implement 32 virtual functions from the SVM interface.

if you instead layer it, you will only need to write wrapper functions for the situations you actually use.

so, try like:

class MySVM
{
    Ptr<ml::SVM> svm;
public:
    MySVM() : svm(ml::SVM::create()) {}

    void doSomehing()
    {
         // use layered, private implementation
         svm->someMethod();
    }
};

also, please avoid using new , and raw pointers in general. either use plain RAII and auto storage, like:

MyClass mysvm;
mysvm.doSomething();

or use a smartpointer, like:

cv::Ptr<MyClass> mysvm = cv::makePtr<MyClass>();
mysvm->doSomething();

please do not try to inherit from ml::SVM, but layer(encapsulate) it.

the long story is: while your class can inherit the interface, this way you can't inherit the hidden implementation, meaning, that you will have to implement all 32 virtual functions from the SVM interface.interface on your own ...

if you instead layer it, you will only need to write wrapper functions for the situations you actually use.

so, try like:

class MySVM
{
    Ptr<ml::SVM> svm;
public:
    MySVM() : svm(ml::SVM::create()) {}

    void doSomehing()
    {
         // use layered, private implementation
         svm->someMethod();
    }
};

also, please avoid using new , and raw pointers in general. either use plain RAII and auto storage, like:

MyClass mysvm;
mysvm.doSomething();

or use a smartpointer, like:

cv::Ptr<MyClass> mysvm = cv::makePtr<MyClass>();
mysvm->doSomething();

please do not try to inherit from ml::SVM, but layer(encapsulate) it.

the long story is: while your class can inherit the interface, this way you can't inherit the hidden implementation, meaning, that you will have to implement all 32 pure virtual functions from the SVM interface on your own ...

if you instead layer it, you will only need to write wrapper functions for the situations you actually use.

so, try like:

class MySVM
{
    Ptr<ml::SVM> svm;
public:
    MySVM() : svm(ml::SVM::create()) {}

    void doSomehing()
bool train(const Mat &features, const Mat &labels)
    {
         // use layered, private implementation
         svm->someMethod();
return svm->train(features, ml::ROW_SAMPLE, labels);
    }
};

also, please avoid using new , and raw pointers in general. either use plain RAII and auto storage, like:

MyClass mysvm;
mysvm.doSomething();

or use a smartpointer, like:

cv::Ptr<MyClass> mysvm = cv::makePtr<MyClass>();
mysvm->doSomething();

please do not try to inherit from ml::SVM, but layer(encapsulate) it.

the long story is: while your class can inherit the interface, this way you can't inherit the hidden implementation, meaning, that you will have to implement all 32 pure virtual functions from the SVM interface on your own ...

if you instead layer it, you will only need to write wrapper functions for the situations you actually use.

so, try like:

class MySVM
{
    Ptr<ml::SVM> svm;
public:
    MySVM() : svm(ml::SVM::create()) {}

    // wrapper:
    bool train(const Mat &features, const Mat &labels)
    {
         // use layered, private implementation
         return svm->train(features, ml::ROW_SAMPLE, labels);
    }
};

also, please avoid using new , and raw pointers in general. either use plain RAII and auto storage, like:

MyClass mysvm;
mysvm.doSomething();

or use a smartpointer, like:

cv::Ptr<MyClass> mysvm = cv::makePtr<MyClass>();
mysvm->doSomething();