I'm getting this error when using ml , opencv 3.1
: error: ‘class cv::ml::TrainData’ has no member named ‘getTestSamples’
Mat vdata = tdata->getTestSamples();
^
what could be the reason for this error ?
here is my ml code :
I have included these in my code
#include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
#include "opencv2/imgcodecs.hpp"
#include <opencv2/highgui.hpp>
#include <opencv2/ml.hpp>
using namespace cv;
using namespace std;
using namespace cv::ml;
Ptr<ml::SVM> svm = ml::SVM::create();
Ptr<ml::TrainData> tdata = ml::TrainData::loadFromCSV("ear.csv",0,0,1);
tdata->setTrainTestSplitRatio(0.8);
Mat data = tdata->getTrainSamples();
Mat labels = tdata->getTrainResponses();
labels.convertTo(labels, CV_32S);
svm->train(data,0,labels);
Mat vdata = tdata->getTestSamples();
Mat vlabels = tdata->getTestResponses();
Mat results;
svm->predict(vdata,results);
Is this actually opencv in version 3.1 which you are using?
Looking at the documentation of TrainData I actually couldn't see the method you seek in the public interface. There is
getTestSampleIdx
andgetTestSampleWeights
but not the one you wish to call.