原文链接:https://blog.csdn.net/cv_jason/article/details/54619505
//#include
#include "highgui.h"
#include "opencv2/opencv.hpp"
#include
using namespace cv;
using namespace std;
using namespace cv;
int main(){VideoCapture capture(0);// 设置摄像头的拍摄属性为 分辨率640x480&#xff0c;帧率30fpscapture.set(CAP_PROP_FRAME_HEIGHT, 480);capture.set(CAP_PROP_FRAME_WIDTH, 640);capture.set(CAP_PROP_FPS, 30.0);// 设置保存视频的格式为AVI&#xff0c;编码为MJPGVideoWriter writer("test.avi", VideoWriter::fourcc(&#39;M&#39;, &#39;J&#39;, &#39;P&#39;, &#39;G&#39;), 30.0, Size(640, 480), true);Mat videoPlay;// 通过总帧数来控制拍摄时间&#xff0c;如果是10s的段视频的话&#xff0c;循环300次int count(300);namedWindow("VideoPlay", WINDOW_NORMAL);while (count--){capture >> videoPlay;writer <}