Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

for opencv3, try like this:

(main difference is, you have to use cv::Ptr, and a factory pattern)

// Class Definition    
class myClass{
    public:
        myClass();

    int predict(const Mat &query) const;

    private:
        Ptr<ml::SVM> svm;
};

// Constructor
myClass::myClass()
{
    svm = Algorithm::load<ml::SVM>load("Some/hard/coded/path/to/a/SVM/File");
}

int myClass::predict(const Mat &query) const
{
    return (int)svm->predict(query);
}

for opencv3, try like this:

(main difference is, you have to use cv::Ptr, and (Algorithm::load is a factory pattern)static template function nowadays)

// Class Definition    
class myClass{
    public:
        myClass();

    int predict(const Mat &query) const;

    private:
        Ptr<ml::SVM> svm;
};

// Constructor
myClass::myClass()
{
    svm = Algorithm::load<ml::SVM>load("Some/hard/coded/path/to/a/SVM/File");
}

int myClass::predict(const Mat &query) const
{
    return (int)svm->predict(query);
}

for opencv3, try like this:

(Algorithm::load is a static template function nowadays)nowadays, it returns a new instance)

// Class Definition    
class myClass{
    public:
        myClass();

    int predict(const Mat &query) const;

    private:
        Ptr<ml::SVM> svm;
};

// Constructor
myClass::myClass()
{
    svm = Algorithm::load<ml::SVM>load("Some/hard/coded/path/to/a/SVM/File");
}

int myClass::predict(const Mat &query) const
{
    return (int)svm->predict(query);
}