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;
    }
  • 相关阅读:
    swing加载图片
    能有效解决问题的提问方法
    资源在线汇总
    如何赢得别人的尊重
    算法总结
    软件工程概述
    java语言基础汇总
    DEBUG技巧汇总
    web技术发展历程
    java中BufferedImage类的用法
  • 原文地址:https://www.cnblogs.com/audi-car/p/4611700.html
Copyright © 2011-2022 走看看