在C ++中使用OpenCV显示图像的问题

时间:2011-07-29 12:32:38

标签: c++ opencv

我希望使用c ++ OpenCV代码显示图像。以下是代码片段:

//Load image
Mat img = imread("Example1.jpg");

//Display in window
namedWindow("Skin");

//display image
imshow("Skin",img);

//returns the matrix size
cout<<img.size()<<endl; // wrong

请帮助我们了解如何显示尺寸。我已多次尝试购买失败。

1 个答案:

答案 0 :(得分:0)

//Load image
Mat img = imread("Example1.jpg");

//Display in window
namedWindow("Skin");

//display image
imshow("Skin",img);

//returns the matrix size
cout << "width= " << img.cols << " height= " << img.rows<< endl; 
//OR if you wanna use the size() getter.
cout << "width= " << img.size().width << " height= " << img.size().height << endl;