zoukankan      html  css  js  c++  java
  • opencv——播放视频

    #include "stdafx.h"
    
    #include <opencv2opencv.hpp>
    #include <iostream>
    #include <string>
    using namespace cv;
    using namespace std;
    
    CvCapture* capture=NULL;
    int g_slider_position=0;
    void onTrackbarSlide(int pos)
    {
     cvSetCaptureProperty(capture,CV_CAP_PROP_POS_FRAMES,pos);
    }
    
    
    int _tmain(int argc, _TCHAR* argv[])
    {
        cvNamedWindow( "Example2", CV_WINDOW_AUTOSIZE );
        //CvCapture* capture = cvCaptureFromAVI( argv[1] ); // either one will work
         capture= cvCreateFileCapture( "test.avi");
         IplImage* frame;
         int frames=cvGetCaptureProperty(capture,CV_CAP_PROP_FRAME_COUNT);
         if(frames!=0)
         {
           cvCreateTrackbar("Position","Example2",&g_slider_position,frames,onTrackbarSlide);
         }
         
        while(1) 
        {
            frame = cvQueryFrame( capture );
            if( !frame ) break;
            cvShowImage( "Example2", frame );
            char c = cvWaitKey(33);
            if( c == 27 ) break;
        }
        cvReleaseCapture( &capture );
        cvDestroyWindow( "Example2" );
    }

  • 相关阅读:
    unitTest单元测试框架
    Day06_页面发布与课程管理
    Day05_RabbitMQ研究
    Day04_页面静态化
    Day04_freemarker
    Day03_CMS页面管理开发
    Java概述练习题
    01_语言概述
    00_编程入门
    德道经
  • 原文地址:https://www.cnblogs.com/nanyangzp/p/3496449.html
Copyright © 2011-2022 走看看