我试图在映射后打印出 rgbMat 的值(在下面的代码中),但出现了一些错误。谁能告诉我哪里出错了?它向我显示以下错误:
g++ `pkg-config --cflags --libs opencv` line1.cpp
l1.cpp: In function ‘int main(int, char**)’:
l1.cpp:28:50: error: request for member ‘at’ in ‘rgbMat’, which is of non-class type ‘CvMat*’
l1.cpp:28:58: error: expected primary-expression before ‘>’ token
l1.cpp:28:62: error: name lookup of ‘x’ changed for ISO ‘for’ scoping
l1.cpp:28:62: note: (if you use ‘-fpermissive’ G++ will accept your code)
我想我在以下行中出错了:
printf("matrix is %u: \n", rgbMat.at<uchar>(y,x));
我的代码是:
IplImage* rgb[3];
float L0[]={
-1,-1,-1,-1,-1,
0, 0, 0, 0, 0,
2, 2, 2, 2, 2,
0, 0, 0, 0, 0,
-1,-1,-1,-1,-1 };
CvMat* rgbMat = cvCreateMat(5, 5, CV_32FC1);
for (int y = 0; y < 5; y++)
{
for (int x = 0; x < 5; x++)
cvmSet(rgbMat, y, x, L0[y*5 + x]);
printf("matrix is %u: \n", rgbMat.at<uchar>(y,x));
}