这是一个愚蠢的问题,因为我对 SVM 还很陌生,
我已经成功地使用 OpenCV 的 HoGDescriptor 提取特征和位置:
vector< float > features;
vector< Point > locations;
hog_descriptors.compute( image, features, Size(0, 0), Size(0, 0), locations );
然后我继续使用 CvSVM 根据我提取的特征训练 SVM。
Mat training_data( features );
CvSVM svm;
svm.train( training_data, labels, Mat(), Mat(), params );
这给了我一个错误:
OpenCV Error: Bad argument (There is only a single class) in cvPreprocessCategoricalResponses, file /opt/local/var/macports/build/
我的问题是,如何将 vector
这些功能到底是什么?它们是由归一化幅度直方图组成的 9 个 bin 吗?
最佳答案
我发现了这个问题,因为我是在测试将特征向量传递到 SVM 以训练它是否正确,所以我没有费心去准备负样本和正样本。
然而,CvSVM 至少需要 2 个不同的类进行训练,这就是它抛出错误的原因。
非常感谢!
关于opencv - 将提取的 HoG 特征提供给 CvSVM 的训练函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11839402/