:::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)
谷歌搜索错误几乎没有帮助。