#include#include using namespace cv; using namespace std; int main() { Mat src; src = imread("D:/lena.png"); if (src.empty()) { printf("could not find the picture!"); return-1; } //方法1 int height = src.rows;//row表示行,rows表示行的总数,即图像的高 int width = src.cols;//col表示列,cols表示列的总数,即图像的宽 //方法2 cout<
2.CV读取视频或调用摄像头:#include#include usingnamespace cv; usingnamespace std; void main() { //VideoCapture capture(0); VideoCapture capture("cat.mp4"); Mat frame; if (capture.isOpened()) //判断视频是否成功打开 { //capture.grab() 从视频文件或捕获设备中抓取下一个帧 while (capture.grab()) { capture >> frame; imshow("读取视频", frame);//显示当前帧 waitKey(50); } } waitKey(); } 后续继续记录opencv新学习的知识。


![OpenCV [C++]-图像大小计算以及获取图像的尺寸和通道数 OpenCV [C++]-图像大小计算以及获取图像的尺寸和通道数](http://www.mshxw.com/aiimages/31/886490.png)
