zoukankan      html  css  js  c++  java
  • OpenCV播放视频带滚动条(3)

     

    演示 :一个带有滚动条的播放视频的代码。

     

    #include "stdafx.h"

    #include <opencv2/core/core.hpp>

    #include <opencv2/contrib/contrib.hpp>

    #include <opencv2/highgui/highgui.hpp>

    #include <opencv2/imgproc/imgproc.hpp>

    #include <opencv2/objdetect/objdetect.hpp>

     

    using namespace cv;

    using namespace std;

    #pragma comment(linker, "/subsystem:"windows" /entry:"mainCRTStartup"")

     

    int g_slider_position = 0;

    int i = 0;

    CvCapture* g_capture = NULL;

    void onTrackingbarSlide(int pos)

    {

        i = pos;

        cvSetCaptureProperty(g_capture, CV_CAP_PROP_POS_FRAMES, pos);

    }

     

    int main(int argc, char** argv[])

    {

        cvNamedWindow("Example3", CV_WINDOW_NORMAL);

        g_capture = cvCreateFileCapture("F:\life\opencv\BuildingCordovaAppsWithVS_high.mp4");

     

        int frames = (int)cvGetCaptureProperty(g_capture, CV_CAP_PROP_FRAME_COUNT);

        if (frames != 0)

        {

            cvCreateTrackbar("Position", "Example3", &g_slider_position, frames, onTrackingbarSlide);

        }

     

        IplImage* frame;

        while (1)

        {

            i++;

            frame = cvQueryFrame(g_capture);

            if (!frame) break;

            cvShowImage("Example3", frame);

            char c = cvWaitKey(33);

            if (c == 27) break;

     

            cvSetTrackbarPos("Position", "Example3", i);

        }

     

        cvReleaseCapture(&g_capture);

        cvDestroyWindow("Example3");

     

        return 0;

    }

     

  • 相关阅读:
    【多视图几何】TUM 课程 第5章 双视图重建:线性方法
    【多视图几何】TUM 课程 第4章 同名点匹配
    【多视图几何】TUM 课程 第3章 透视投影
    SpringMVC配置实例
    sqlserver的触发器练习实例
    zTree学习实例
    浅谈JVM与内存分配
    Ajax的简单实用实例
    Sqlserver事务备份和还原实例
    JQueryEasyUI学习简单Demo
  • 原文地址:https://www.cnblogs.com/pengzhen/p/4952221.html
Copyright © 2011-2022 走看看