zoukankan      html  css  js  c++  java
  • OpenCv 012---视频文件读写

    1 前备知识

    null

    2 所用到的主要OpenCv Class

    VideoCapture capture;
        capture.open("G:\CVworkstudy\program_wwx\研习社140课时\ZhaiZhigang140\vtest.avi");
    VideoWriter writer("G:\CVworkstudy\program_wwx\研习社140课时\ZhaiZhigang140\test.avi", CV_FOURCC('D', 'I', 'V', 'X'), fps, S, true);

    3 程序代码

    同OpenCv研习社例程代码

    #include<opencv2/opencv.hpp>
    #include<iostream>
    
    using namespace cv;
    using namespace std;
    
    int main(int argc, char** argv) {
        // 打开摄像头
        // VideoCapture capture(0); 
    
        // 打开文件
        VideoCapture capture;
        capture.open("G:\CVworkstudy\program_wwx\研习社140课时\ZhaiZhigang140\vtest.avi");
        if (!capture.isOpened()) {
            printf("could not read this video file...
    ");
            return -1;
        }
        Size S = Size((int)capture.get(CV_CAP_PROP_FRAME_WIDTH),
            (int)capture.get(CV_CAP_PROP_FRAME_HEIGHT));
        int fps = capture.get(CV_CAP_PROP_FPS);
        printf("current fps : %d 
    ", fps);
        VideoWriter writer("G:\CVworkstudy\program_wwx\研习社140课时\ZhaiZhigang140\test.avi", CV_FOURCC('D', 'I', 'V', 'X'), fps, S, true);
    
        Mat frame;
        namedWindow("camera-demo", CV_WINDOW_AUTOSIZE);
        while (capture.read(frame)) {
            imshow("camera-demo", frame);
            writer.write(frame);
            char c = waitKey(50);
            if (c == 27) {
                break;
            }
        }
        capture.release();
        writer.release();
        waitKey(0);
        return 0;
    }

    4 运行结果

    display:ignore

    5 扩展及注意事项

    null

    One day,I will say "I did it"
  • 相关阅读:
    pwdLastSet AD
    快递条形码类型
    Sharepoint 应用程序池自动停止
    Visual Studio 2015安装后“无法启动iis express web 服务器”
    Knockout自定义绑定数据逻辑
    Knockout基本绑定数据
    TableAttribute同时存在于
    微服务架构下的鉴权,怎么做更优雅?
    使用 Yopto 插件给商品添加评论
    Docker 基本概念
  • 原文地址:https://www.cnblogs.com/Vince-Wu/p/11182420.html
Copyright © 2011-2022 走看看