#include <iostream>
#include<highgui.h>
#include "cv.h"
using namespace std;
using namespace cv;
int g_slide_position=0;
CvCapture*g_capture =NULL;
void ontrackbarSlide(int pos)
{
cvSetCaptureProperty(g_capture,CV_CAP_PROP_POS_FRAMES,pos);
}
int main(int argc, char** argv)
{
cvNamedWindow("Example2", CV_WINDOW_AUTOSIZE);
g_capture = cvCreateFileCapture("local .avi");//这个是视频文件的名称
int frames=(int)cvGetCaptureProperty(g_capture,CV_CAP_PROP_FRAME_COUNT);
if (frames!=0)
{
cvCreateTrackbar("position","Example2",&g_slide_position,frames,ontrackbarSlide);//position是滑块的当前位置
}
IplImage* frame;
while(1)
{
frame = cvQueryFrame(g_capture);
if(!frame)
break;
cvShowImage("Example2",frame);
char c = cvWaitKey(33);
/* if(c == 27)
break;*/
}
cvReleaseCapture(&g_capture);
cvDestroyWindow("Example2");
}