Chinaunix首页 | 论坛 | 博客
  • 博客访问: 296439
  • 博文数量: 32
  • 博客积分: 665
  • 博客等级: 上士
  • 技术积分: 370
  • 用 户 组: 普通用户
  • 注册时间: 2009-07-25 11:20
文章分类

全部博文(32)

文章存档

2023年(1)

2021年(1)

2020年(2)

2018年(3)

2014年(1)

2013年(2)

2012年(9)

2011年(9)

2010年(2)

2009年(2)

分类: Delphi

2011-03-13 20:40:12

    #include "stdafx.h"
    #include "cv.h"
    #include "highgui.h"
    int g_slider_position = 0;
    CvCapture *g_capture  = NULL;
    void onTrackbarSlide(int);
    int APIENTRY _tWinMain(HINSTANCE hInstance,
                         HINSTANCE hPrevInstance,
                         LPTSTR    lpCmdLine,
                         int       nCmdShow)
    {
  1. cvNamedWindow("Example3",CV_WINDOW_AUTOSIZE);
  2.     g_capture = cvCreateFileCapture("d:\\cv.avi");
  3.     int frames = (int) cvGetCaptureProperty(g_capture,CV_CAP_PROP_FRAME_COUNT);

  4.     if(frames != 0)
  5.     {
  6.         cvCreateTrackbar("Position","Example3",&g_slider_position,frames,onTrackbarSlide);
  7.     }
  8.     IplImage *frame;
  9.     while(1)
  10.     {
  11.         frame = cvQueryFrame(g_capture);

  12.         if(!frame) break;

  13.         cvShowImage("Example3",frame);
  14.         cvSetTrackbarPos("Position","Example3", ++g_slider_position);
  15.         char c = cvWaitKey(33);
  16.         if(c == 27) break;
  17.     }

  18.     cvReleaseCapture(&g_capture);
  19.     cvDestroyWindow("Example3");
  20.     return 0;
  21. }

  22. void onTrackbarSlide(int pos)
  23. {
  24.     cvSetCaptureProperty(g_capture,CV_CAP_PROP_POS_FRAMES,pos);
  25. }
阅读(1482) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~