#include <opencv2/highgui/highgui.hpp> #include <cv.h> #include <iostream> using namespace cv; using namespace std; int g_slider_position = 0; CvCapture *g_cap = nullptr; void onTrackbarslide(int pos) { cvSetCaptureProperty(g_cap,CV_CAP_PROP_POS_FRAMES,pos); } void main() { cvNamedWindow("example3",CV_WINDOW_AUTOSIZE); g_cap = cvCreateFileCapture("D:\\1.wmv"); int frames = static_cast<int>(cvGetCaptureProperty(g_cap,CV_CAP_PROP_FRAME_COUNT)); if (frames != 0) { cvCreateTrackbar("position","example3",&g_slider_position,frames,onTrackbarslide); } IplImage *frame; while(1) { frame = cvQueryFrame(g_cap); if(!frame) break; cvShowImage("example3",frame); char c = waitKey(33); if (c == 27) { break; } } cvReleaseCapture(&g_cap); cvDestroyWindow("example3"); system("pause"); }
和上一个的问题是一样的,还有一个问题没有解决就是这个滚动条并不能随着视频的播放而滚动