我想获取图像的宽度和高度,我该如何在 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;
或大小
cout << "Width : " << src.size[1] << endl;
cout << "Height: " << src.size[0] << endl;
关于python - 如何在 OpenCV 中获取图像的宽度和高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32971241/