OpenCV中的SVM:Visual Studio 2008报告错误错误(或者是对吗?) [英] SVM in OpenCV: Visual Studio 2008 reported error wrongly (or is it right?)

查看:189
本文介绍了OpenCV中的SVM:Visual Studio 2008报告错误错误(或者是对吗?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用MS Visual Studio 2008,OpenCV,C ++和SVM进行OCR相关项目。至少我可以运行代码,直到昨天,当我打开项目继续工作,VS报告此错误:

I'm using MS Visual Studio 2008, OpenCV, C++ and SVM for a OCR-related project. At least I can run the code until yesterday, when I open the project to continue working, 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 *'

之前没有发生,我没有改变任何与它相关的代码(我只是改变了内核的参数)。

It didn't happen before and I haven't changed any code relating to it (I only changed the parameters for the kernel).

代码错误是:

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

如果我在代码上悬停,我还是得到这个提示: image

If I hover on the code, I still got this tip: image.

这意味着我的语法是没有错。那么为什么VS会报告这样的错误?

Which means my syntax isn't wrong. So why do VS bother to report such an error?

推荐答案

问题是你使用Opencv c ++引用比c引用。我的意思是CvMat是Opencv的C部分,而cv :: Mat属于cv命名空间是c ++部分。所以我的建议是将其转换为必需的格式。这里有一个到opencv cheat表的链接,只是查看前几行代码。它会告诉你如何做到。
从Mat转换为CvMat

The problem is you're using Opencv c++ reference than c reference. I mean CvMat is of C part of Opencv, Whereas cv:: Mat which belongs to "cv" namespace is of c++ part. So my suggestion is convert it into required format. Here is a link to the opencv cheat sheet, just check out the first few lines of code. it will tell you how to do it. Convert from Mat to CvMat

这篇关于OpenCV中的SVM:Visual Studio 2008报告错误错误(或者是对吗?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆