// 2_3.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <cv.h>
#include <cvcam.h>
#include <cxcore.h>
#include <highgui.h>
#pragma comment(lib,"cv.lib")
#pragma comment(lib,"cvcam.lib")
#pragma comment(lib,"cxcore.lib")
#pragma comment(lib,"highgui.lib")
int g_nSliderPostion = 0;
CvCapture *g_pCapture = NULL;
void OnTrackbarSlider(int nPostion)
{
cvSetCaptureProperty(
g_pCapture,
CV_CAP_PROP_POS_FRAMES,
nPostion
);
}
int main(int argc, char* argv[])
{
g_pCapture = cvCreateFileCapture(argv[1]);
assert(g_pCapture != NULL);
IplImage *pImage = cvQueryFrame(g_pCapture);
int nFrameAmount = (int)cvGetCaptureProperty(
g_pCapture,
CV_CAP_PROP_FRAME_COUNT
);
if (nFrameAmount != 0)
{
cvNamedWindow(argv[2]);
cvCreateTrackbar(
argv[3],
argv[2],
&g_nSliderPostion,
nFrameAmount,
OnTrackbarSlider
);
}
while ( (pImage = cvQueryFrame(g_pCapture)) != NULL )
{
cvShowImage(argv[2],pImage);
if (27 == cvWaitKey(30))
{
break;
}
}
cvReleaseCapture(&g_pCapture);
cvDestroyWindow(argv[2]);
return 0;
}