1
votes

int main(int argc, char* argv[]){

Mat aObj, bObj;

string fList("horse.jpg");

for(int i = 0; i < 10; i++){

    aObj = imread(fList, CV_32FC1);
}
string fRes("horse-2.jpg");

bObj = imread(fList, CV_32FC1);

CvKNearest C(aObj, bObj); //error after here

return 0;

}

AFAIK CV_32FC1 is supposed to do the trick and since I am using opencv 2.2 and other stuff runs well I don't get the problem. Mat is a valid argument type (Intellisense shows the options in the box), using visual studio 2010. Debugging taced the problem to inner_functions.cpp in ../../Opencv2.2.0/modules/ml/src/ The function raising the error is cvCheckTrainData. Please help.

1

1 Answers

0
votes

I know this post is rather old; I came here googling something different. However I've uploaded a source file that shows you how to use the different machine learning algorithms with OpenCV2. It's in my github account at https://github.com/bytefish/opencv/blob/master/machinelearning-src/main.cpp.

Best regards, Philipp.