• 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;

    }

     

  • 相关阅读:
    linux正则表达式
    linux监控值free命令详解
    loadrunner 中数组的定义
    管线工具sed和正则表达式
    web_link()参数化
    mysql执行插入时性能优化
    linux关闭防火墙
    linux系统中变量和环境变量
    mysql源码安装与基本优化配置
    Memory Consistency Erros
  • 原文地址:https://www.cnblogs.com/pengzhen/p/4952221.html
Copyright © 2020-2023  润新知