3,881
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include "cxcore.h"
#include "cv.h"
#include "highgui.h"
using namespace std;
CvCapture *capture = NULL;
int frame_count = 0;
int g_capture;
void track_change(int pos){
cvSetCaptureProperty(capture, CV_CAP_PROP_POS_FRAMES, pos);
frame_count = pos;
}
int main()
{
cvNamedWindow("show");
capture = cvCreateFileCapture("F:\\download\\itudou\\xx5.avi");
int frame_sum = cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_COUNT);
if(frame_sum != 0){
cvCreateTrackbar("track_name", "show", &g_capture, frame_sum, track_change);
}
IplImage *image = NULL;
while(1){
image = cvQueryFrame(capture);
if(!image){
break;
}
cvShowImage("show",image);
char c = cvWaitKey(33);
if(c == 27)
{
break;
}
cvSetTrackbarPos("track_name","show", frame_count); //运行两帧就结束了 为什么呢?
frame_count ++;
}
cvReleaseCapture(&capture);
cvDestroyWindow("show");
return 0;
}