opencv中的视频的读入

#include"stdafx.h"
#include"opencv2/opencv.hpp"

using namespace cv;
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 argc,char** argv)
{
cvNamedWindow("example",CV_WINDOW_AUTOSIZE);
g_capture=cvCreateFileCapture("F://BaiduYunDownload//ÀäÄ®-СÈý.avi");
int frames = (int) cvGetCaptureProperty(
g_capture,
CV_CAP_PROP_FRAME_COUNT
);
if(frames!=0)
{
cvCreateTrackbar(
"position",
"example",
&g_slider_position,
frames,
onTrackbarSlider
);
IplImage* frame;
while(1)
{
frame=cvQueryFrame(g_capture);
if(!frame)
break;
cvShowImage("example",frame);
char c=cvWaitKey(33);
if(c==27)
break;

}
cvReleaseCapture(&g_capture);
cvDestroyWindow("example");


}

return 0;
}

原文地址:https://www.cnblogs.com/Peit/p/5966160.html