:::c++
#include <opencv2/opencv.hpp>
#include <stdio.h>
int main(int argc, char** argv){
int x = cv::CV_8UC4;
std::cout << x;
return 0;
}
我实际上是在尝试创建cv::Mat(r,c,cv::CV_8UC4,ptr,0)
,但为了识别错误,我创建了上述内容。使用g ++或clang ++进行编译都会产生此错误(clang版本):
test.cpp:4:17: error: expected unqualified-id
int x = cv::CV_8UC4;
^
/usr/include/opencv2/core/types_c.h:584:17: note: expanded from macro 'CV_8UC4'
#define CV_8UC4 CV_MAKETYPE(CV_8U,4)
^
/usr/include/opencv2/core/types_c.h:578:32: note: expanded from macro 'CV_MAKETYPE'
#define CV_MAKETYPE(depth,cn) (CV_MAT_DEPTH(depth) + (((cn)-1) << CV_CN_SHIFT))
^
/usr/include/opencv2/core/types_c.h:576:33: note: expanded from macro 'CV_MAT_DEPTH'
#define CV_MAT_DEPTH(flags) ((flags) & CV_MAT_DEPTH_MASK)
谷歌搜索错误没什么帮助。
答案 0 :(得分:14)
cv::CV_8UC4
只是CV_8UC4
由于历史原因以及与C版本的互操作,宏不在cv :: namespace
中