您的位置:首页 > 其它

error: (-5) in the case of classification problem the responses must be cate

2018-03-09 09:23 656 查看
气晕我~~~~~~~~~~~~~~~~~~~~~~~~~~~

OpenCV3.0以后的hog+svm中,调用函数svm->train(data_mat, ROW_SAMPLE, res_mat);对样本进行训练时需要注意data_mat和res_mat的类型。

其中:data_mat必须是Mat类型,其数据类型为32位的浮点数CV_32FC1,其宽度为样本的个数,高度为HOG特征的维数;

res_mat必须是Mat类型,其数据类型为32位整数CV_32SC1,其宽度位样本的个数,高度为1。

for (vector<float>::iterator iter = descriptors.begin(); iter != descriptors.end(); iter++)
{
data_mat.at<float>(i, j) = descriptors[j];
}
res_mat.at<int>(i, 0) = img_catg[i];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐