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