源代码:
#include "stdafx.h"
#include "cv.h"
#include "highgui.h"
int g_slider_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( "Video_play_control", CV_WINDOW_AUTOSIZE );
g_capture = cvCreateFileCapture(argv[1]);
int frames = (int) cvGetCaptureProperty
(
g_capture,
CV_CAP_PROP_FRAME_COUNT
);
if(frames != 0)
{
cvCreateTrackbar
(
"Position",
"Video_play_control",
&g_slider_position,
frames,
onTrackbarSlide
);
}
IplImage* frame;
while(1)
{
frame = cvQueryFrame(g_capture);
if(!frame) break;
cvShowImage("Video_play_control",frame);
char c = cvWaitKey(33);
if(c == 7)
break;
cvDestroyWindow( "Video" );//销毁窗口
return 0;
}
#include "stdafx.h"
#include "cv.h"
#include "highgui.h"
int g_slider_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( "Video_play_control", CV_WINDOW_AUTOSIZE );
g_capture = cvCreateFileCapture(argv[1]);
int frames = (int) cvGetCaptureProperty
(
g_capture,
CV_CAP_PROP_FRAME_COUNT
);
if(frames != 0)
{
cvCreateTrackbar
(
"Position",
"Video_play_control",
&g_slider_position,
frames,
onTrackbarSlide
);
}
IplImage* frame;
while(1)
{
frame = cvQueryFrame(g_capture);
if(!frame) break;
cvShowImage("Video_play_control",frame);
char c = cvWaitKey(33);
if(c == 7)
break;
}
cvReleaseCapture( &g_capture ); //释放图像cvDestroyWindow( "Video" );//销毁窗口
return 0;
}