(1)
#include <cv.h>
报错:无法找到cv.h
解决方法:
//替换为
#include <opencv2/imgproc.hpp>
(2)
Mat imgSrc;
CvMat tempImg = imgSrc;
报错:不存在用户定义的cv::Mat到CvMat的转换
找到CvMat的定义:
//在types_c.h文件中
typedef struct CvMat
{
int type;
int step;
/* for internal use only */
int* refcount;
int hdr_refcount;
union
{
uchar* ptr;
short* s;
int* i;
float* fl;
double* db;
} data;
#ifdef __cplusplus
union
{
int rows;
int height;
};
union
{
int cols;
int width;
};
#else
int rows;
int cols;
#endif
#if defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)
CvMat() {}
CvMat(const cv::Mat& m) { *this = cvMat(m); }
#endif
}
CvMat;
其中cv::Mat到CvMat的转换函数如下:
CvMat(const cv::Mat& m) { *this = cvMat(m);
解决办法:
CvMat tempImg = cvMat(imgSrc);
(3)
cvtColor(m_SrcImg, m_SrcImg, cv_BGR2GRAY);
cv_BGR2GRAY未定义标识符
解决方法:
cvtColor(m_SrcImg, m_SrcImg, COLOR_BGR2GRAY);