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;

    }

     

  • 相关阅读:
    JZOJ1495 宝石
    JZOJ1496 页
    jzoj1497. 景点中心
    2019.8.2总结
    学习进度报告2021/3/19
    学习进度报告2021/3/18
    《学会提问》读书笔记2
    学习进度报告2021/3/17
    学习进度报告2021/3/16
    学习进度报告2021/3/15
  • 原文地址:https://www.cnblogs.com/pengzhen/p/4952221.html
Copyright © 2011-2022 走看看