Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

ok, now you can setup your machine learning:

we need each feature on a row, and a resp. label:

Mat trainData; // initially empty.
Mat trainLabels;
for each img
{

    // calculate lbp histo:
    Mat histogram = ....
    trainData.push_back(histogram);         
    trainLabel.push_back(1); // e.g. stone=1, grass=2, etc.

}

Ptr<ml::SVM> svm = ml::SVM::create();
svm->setKernel(ml::SVM::LINEAR); //maybe, here's where the real work starts !

svm->train(trainData, ml::ROW_DATA, trainLabels);

later, predict:

Mat histogram = ...
int label = (int)svm->predict(histogram);