ShowAvi_Trackbar_加载视频,并添加拖动条
ShowAvi_Trackbar.c
/*
* Copyright (c++) 2013,合肥学院智能视觉与检测实验室
* All rights reserved.
*
* 文件名称:ShowAvi_Trackbar.c
* 摘 要:加载视频,并添加拖动条
*
* 当前版本:1.0
* 作 者:高全宁
* 完成日期:2013年5月7日
*
*亲测有效
*/
#include "stdafx.h"
#include "cv.h"
#include "highgui.h"
#include "cxcore.h"
CvCapture* g_capture = NULL;
int g_slider_pos = 0;
int frame_count = 0;
void onTrackbarSlider(int pos)
{
cvSetCaptureProperty(g_capture, CV_CAP_PROP_POS_FRAMES, pos);
frame_count = pos;
}
int main()
{
cvNamedWindow("show");
g_capture = cvCreateFileCapture("F:\\who_is_your_favourite.avi");
int frames = (int)cvGetCaptureProperty(g_capture,CV_CAP_PROP_FRAME_COUNT);
if (frames > 0)
{
cvCreateTrackbar("position","show",&g_slider_pos,frames,onTrackbarSlider);
}
IplImage* frame;
while (1)
{
frame = cvQueryFrame(g_capture);
if (!frame)
{
break;
}
cvShowImage("show",frame);
char c = cvWaitKey(33);
if(c == 27)
{
break;
}
cvSetTrackbarPos("position","show",frame_count);
frame_count++;
}
cvReleaseCapture(&g_capture);
cvDestroyWindow("show");
return 0;
}
ShowAvi_Trackbar.cpp
待补