Problem of displaying image using OpenCV in C++
I wish to display image using c++ OpenCV code. Below are the code fragment:
//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
Please help on how to display the size. I have tried many times buy fail.
//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;
精彩评论