ssjie
#include <opencv2/opencv.hpp>
#include <iostream>

using namespace std;
using namespace cv;
//opencv3.0 alpha加载并播放视频 2015.11.07
int main(int argc, char* argv[])
{
    const char* vedioName = "D:/演示源码/视频/djxzBrightness.mp4";
    cv::VideoCapture captureVedio(vedioName);
    if (!captureVedio.isOpened()){
        std::cout << "无法打开视频文件!\n";
        cv::waitKey(0);
        return -1;
    }
    cv::Mat_<cv::Vec3b> frameVedio;
    bool isStop = false;
    cv::namedWindow("frameVedio", 1);
    //判断视频文件结束
    while (!isStop)
    {
        //captureVedio.read(frameVedio);
        captureVedio >> frameVedio;
        //循环获得视频文件的帧
        if (frameVedio.data){
            cv::imshow("frameVedio", frameVedio);
            //读取时间,遇到esc退出
            if (cv::waitKey(30) == 27){ isStop = true; }
        }
        else{
            //播放完毕
            isStop = true;
        }
    }
    captureVedio.release();
    //销毁窗口
    cv::destroyWindow("frameVedio");
    return 0;
}

 

分类:

技术点:

相关文章:

  • 2021-12-15
  • 2021-11-28
  • 2021-05-19
  • 2022-12-23
  • 2022-12-23
  • 2021-12-16
  • 2021-10-05
  • 2022-02-20
猜你喜欢
  • 2021-12-15
  • 2021-05-01
  • 2021-07-31
  • 2022-01-23
  • 2021-06-14
  • 2021-04-05
  • 2022-12-23
相关资源
相似解决方案