Opencv——播放视频(带滚动条)

#include"highgui.h"
#include"cv.h" int g_slider_position = ;
CvCapture* g_capture = NULL;
void onTrackbarSlide(int pos){
cvSetCaptureProperty(g_capture,
CV_CAP_PROP_POS_FRAMES, pos);//CV_CAP_PROP_POS_FRAMES - 将被下一步解压/获取的帧索引,以0为起点
}
int main()
{
g_capture = cvCreateFileCapture("D:\\Opencv\\testData\\video.avi");
cvNamedWindow("Video", CV_WINDOW_AUTOSIZE);
IplImage* frame;
int frames = (int)cvGetCaptureProperty(g_capture,
CV_CAP_PROP_FRAME_COUNT);//CV_CAP_PROP_FRAME_COUNT - 视频文件中帧的总数
if (frames != ){
cvCreateTrackbar("Position", "Video", &g_slider_position, frames, onTrackbarSlide); }
while (){
frame = cvQueryFrame(g_capture);
if (!frame) break;
cvShowImage("Video", frame);
cvWaitKey();
}
cvReleaseCapture(&g_capture);
cvDestroyWindow("Video");
return ;
}

Opencv——播放视频(带滚动条)

上一篇:ffmpeg和opencv 播放视频文件和显示器


下一篇:Ext JS添加子组件的误区