如何在OpenCV中获得图像宽度和高度
How to get image width and height in OpenCV?
我想获得图像宽度和高度,我如何在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;
或size
cout << "Width : " << src.size[1] << endl;
cout << "Height: " << src.size[0] << endl;
对于python中的openCV,您也可以这样做:
img = cv2.imread('myImage.jpg')
height, width, channels = img.shape
相关文章:
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 如何使用OpenCV将RBG图像转换为HSV,并将H、S和V值保存为C++中的3个独立图像
- OpenCV EqualizeHist()从彩色图像创建黑白图像
- 将"打开的CV图像"中的"颜色"转换为整数格式
- 平均图像时图像损坏
- 在C++中使用GDAL可以将图像的像素坐标转换为lat,long吗
- 如何将图像传输到c++(dll)中的缓冲区,然后在c#的缓冲区中读/写
- Vulkan验证层不断在VkQueuePresentKHR()上抛出图像布局错误
- 免费图像零宽度和高度
- Q::比例高度变换模式返回空图像
- 图像部分的开口高度/宽度
- 使用逐位运算符查找bmp图像的宽度和高度
- 如何使用opengl或dx从网格中生成深度(高度)图像
- 如何在OpenCV中获得图像宽度和高度
- 用c++实现图像的高度和宽度
- 如何加载具有负高度的图像
- 复制图像后,断言失败(大小>宽度0 &&&大小.高度>0)
- 抛出了一个奇怪的异常:在SFML中获取精灵图像的高度
- 从标题(宽度、高度等)获取图像信息,而无需打开它
- 佳能EDSDK如何获得实时视图图像的宽度和高度