#include "stdafx.h"
#include <opencv2\opencv.hpp>
#include <iostream>
#include <string>
using namespace cv;
using namespace std;
CvCapture* capture=NULL;
int g_slider_position=0;
void onTrackbarSlide(int pos)
{
cvSetCaptureProperty(capture,CV_CAP_PROP_POS_FRAMES,pos);
}
int _tmain(int argc, _TCHAR* argv[])
{
cvNamedWindow( "Example2", CV_WINDOW_AUTOSIZE );
//CvCapture* capture = cvCaptureFromAVI( argv[1] ); // either one will work
capture= cvCreateFileCapture( "test.avi");
IplImage* frame;
int frames=cvGetCaptureProperty(capture,CV_CAP_PROP_FRAME_COUNT);
if(frames!=0)
{
cvCreateTrackbar("Position","Example2",&g_slider_position,frames,onTrackbarSlide);
}
while(1)
{
frame = cvQueryFrame( capture );
if( !frame ) break;
cvShowImage( "Example2", frame );
char c = cvWaitKey(33);
if( c == 27 ) break;
}
cvReleaseCapture( &capture );
cvDestroyWindow( "Example2" );
}