开发者

Problem of displaying image using OpenCV in C++

开发者 https://www.devze.com 2023-03-23 15:36 出处:网络
I wish to display image using c++ OpenCV code. Below are the code fragment: //Load image Mat img = imread(\"Example1.jpg\");

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;
0

精彩评论

暂无评论...
验证码 换一张
取 消