Opencv使用滑块控制视频的播放

#include "highgui.h"
#include "cv.h"


int g_slider_position = 0;
CvCapture* g_capture = NULL;


void onTrackbarSlider(int pos)
{
cvSetCaptureProperty(g_capture,CV_CAP_PROP_POS_FRAMES,pos);

}


int main()
{
int temp_pos = 23;
cvNamedWindow("Example3",CV_WINDOW_AUTOSIZE);
g_capture = cvCreateFileCapture("G:\\kkk.avi");


int frames = (int)cvGetCaptureProperty(g_capture, CV_CAP_PROP_FRAME_COUNT);
if (frames != 0)
{
cvCreateTrackbar("Position", "Example3", &g_slider_position, frames, onTrackbarSlider);

}
IplImage * frame;
while (1)
{
frame = cvQueryFrame(g_capture);


if (!frame)


{


break;


}
cvShowImage("Example3", frame);


char c = cvWaitKey(33);


if (c == 27)


{


break;


}
}



cvReleaseCapture(&g_capture);
cvDestroyWindow("Example3");


return 0;

你可能感兴趣的:(Opencv使用滑块控制视频的播放)