首页 > 其他 > 详细

opencv 操作本地摄像头实现录像

时间:2015-06-30 23:28:20      阅读:317      评论:0      收藏:0      [点我收藏+]

直接上代码:

// demo1.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include <iostream>
using namespace std;
#include <core/core.hpp>
#include <highgui/highgui.hpp>
#include <cmath>
#include <ctime>
using namespace cv;

int main()
{
    Mat frame;  //mat数据类型
    VideoCapture capture(0);
    capture >> frame;    //流操作
    VideoWriter writer("e:\\VideoTest.avi", CV_FOURCC(M, J, P, G), 25.0, Size(frame.cols,frame.rows));
    int f=frame.cols;
    int p=frame.rows;
    //cout<<frame.rows<<endl;
    while (capture.isOpened())
    {
    int start=clock();
    capture >> frame;    //流操作
    writer << frame;
    imshow("video", frame);
    if (cvWaitKey(30) == 113)  //按下q键  程序退出
    {
    break;
    }
    cout<<"程序执行过程耗时:"<<clock()-start<<"毫秒"<<endl;
    }
    cout<<"图像宽度为:"<<frame.cols<<endl;
    cout<<"图像高度为:"<<frame.rows<<endl;
    cout<<frame.size<<endl;
    return 0;
}

opencv 操作本地摄像头实现录像

原文:http://www.cnblogs.com/audi-car/p/4611700.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!