您的位置:首页 > 其它

打开笔记本摄像头保存视频文件

2012-08-17 17:39 393 查看
在自己的笔记本上运行一下程序,保存成功。

但是,当试图改变VideoWriter中的成员函数的frameSize的时候,被保存的视频文档为0kb或者是很小的文件,反正不能读取。 CV_WRAP VideoWriter(const string& filename, int fourcc, double fps, Size frameSize, bool isColor=true);

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>

using namespace cv;

void main()
{
VideoCapture capture(0);
Size S = Size((int) capture.get(CV_CAP_PROP_FRAME_WIDTH),    //Acquire input size
(int) capture.get(CV_CAP_PROP_FRAME_HEIGHT));
VideoWriter writer("VideoTest.avi", CV_FOURCC('M', 'J', 'P', 'G'), 8.0, S);
Mat frame;

while (capture.isOpened())
{
capture >> frame;
writer << frame;
imshow("video", frame);
if (cvWaitKey(20) == 27)
{
break;
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: