为什么"train data must be floating-point matrix"运行时错误?



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应该做到这一点,因为我使用opencv 2.2和其他东西运行良好,我没有得到这个问题。Mat是一个有效的参数类型(Intellisense在框中显示选项),使用visual studio 2010。debug在../../Opencv2.2.0/modules/ml/src/中的inner_functions.cpp中找到了这个问题引发错误的函数是cvCheckTrainData。请帮助。

我知道这篇文章相当老;我来这里搜索一些不同的东西。然而,我上传了一个源文件,向您展示如何在OpenCV2中使用不同的机器学习算法。它在我的github帐户https://github.com/bytefish/opencv/blob/master/machinelearning-src/main.cpp。

祝你生日快乐。

最新更新