zoukankan      html  css  js  c++  java
  • opencv 操作本地摄像头实现录像

    直接上代码:

    // 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;
    }
  • 相关阅读:
    java操作Redis
    Redis安装和基本操作
    IDEA使用教程+JRebel破解
    java环境配置
    qtp10安装步骤(比较完整)
    c++第一章1.6
    软件测试第二章作业
    c++作业22题
    c++第二周阶段小测2
    oracle12c数据库第一周小测验
  • 原文地址:https://www.cnblogs.com/audi-car/p/4611700.html
Copyright © 2011-2022 走看看