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" );
    }

  • 相关阅读:
    【Rust】匹配绑定
    【Rust】iflet
    【Rust】结构体匹配
    【Rust】闭包
    【Rust】函数
    【Rust】方法
    【Rust】whilelet
    【Rust】匹配保护
    【Rust】闭包捕获变量
    优先队列 安静点
  • 原文地址:https://www.cnblogs.com/nanyangzp/p/3496449.html
Copyright © 2011-2022 走看看