SVM in OpenCV: Visual Studio 2008 incorrectly reported an error (or is this correct?)

I am using MS Visual Studio 2008, OpenCV, C ++ and SVM for an OCR related project. At least I can run the code until yesterday, when I open the project to continue, VS reported this error:

error C2664: 'bool CvSVM::train(const CvMat *,const CvMat *,const CvMat *,const CvMat *,CvSVMParams)' : cannot convert parameter 1 from 'cv::Mat' to 'const CvMat *'


This hasn't happened before and I haven't changed any code associated with it (I've only changed the parameters for the kernel).

Received error:

Mat curTrainData, curTrainLabel;
CvSVM svm;
svm.train(curTrainData, curTrainLabel, Mat(), Mat(), params);


If I find the code, I still have this tip: image .

This means my syntax is not wrong. So why is VS bothering with this error message?


source to share

1 answer

The problem is you are using the Opencv C ++ link than the c link. I mean CvMat has a C part of Opencv, and cv :: Mat, which belongs to the cv namespace, has a C ++ part. So my suggestion will convert it to the required format. Below is the link to the opencv workaround file sheet, just check the first few lines of code. he will tell you how to do it. Convert from Mat to CvMat



All Articles