VideoCapture video0(0);
int vh = 480; int vw = 640;
video0.set(CV_CAP_PROP_FRAME_WIDTH,vw);
video0.set(CV_CAP_PROP_FRAME_HEIGHT, vh);
Mat img0;
namedWindow("video", 0);
Size vs(static_cast<int>(vw), static_cast<int>(vh));
VideoWriter videowr("test0.avi",CV_FOURCC('M','J','P','G'),25,vs);
if (!videowr.isOpened())
{
cout << "初始化VideoWriter失败!" << endl;
return;
}
while (true)
{
video0.read(img0);
imshow("video", img0);
videowr.write(img0);
int c = cvWaitKey(5);
if (c==27)
{
break;
}
}
destroyWindow("video");
videowr.release();
使用Opencv对摄像头进行录相
最新推荐文章于 2022-09-10 23:52:47 发布