我想获取图像的宽度和高度,如何在OpenCV中实现呢?
例如:
Mat src = imread("path_to_image");
cout << src.width;
是对的吗?
您可以使用rows
和cols
:
cout << "Width : " << src.cols << endl;
cout << "Height: " << src.rows << endl;
或size()
:
cout << "Width : " << src.size().width << endl;
cout << "Height: " << src.size().height << endl;