Error: Floating Point exception in OpenCV, SVM train

Error: Floating Point exception in OpenCV, SVM train

我正在尝试使用 HOG 特征提取器的描述符值来训练 svm。

//pRow, nRow, pCol, nCol are positive and negative columns and rows.
Mat posneg_descriptor_mat( pRow + nRow, pCol, CV_32FC1 );

// data is descriptor values
memcpy(posneg_descriptor_mat.data, pMat.data, sizeof(float) * pMat.cols * pMat.rows );
int startP = sizeof(float) * pMat.cols * pMat.rows;
memcpy(&(posneg_descriptor_mat.data[ startP ]), nMat.data, sizeof(float) * nMat.cols * nMat.rows );
//data labeling
Mat labels( pRow + nRow, 1, CV_32FC1, Scalar(-1.0) );
    labels.rowRange( 0, pRow ) = Scalar( 1.0 );


Ptr<SVM> svm = SVM::create();
svm->setType(SVM::C_SVC);
svm->setKernel(SVM::LINEAR);
svm->setTermCriteria(TermCriteria(TermCriteria::MAX_ITER, 10000, 1e-6));

Ptr<TrainData> td =TrainData::create(posneg_descriptor_mat, ROW_SAMPLE, labels);

当代码在错误(浮点异常(核心转储))下面的行中时:

svm->trainAuto(td);

CV_32FC1 更改为 CV_32SC1 解决了问题。好像 response 不能是 float.