Linux教程網
用OpenCV讀取視頻的簡單例子:
- #include "stdafx.h"
- #include "cv.h"
- #include <cxcore.h>
- #include <highgui.h>
-
-
- int main(int argc,char** argv)
- {
- CvCapture* g_capture = cvCreateFileCapture("D:\\test2.avi"); // 視頻地址
-
-
- IplImage* frame;
- string originVideoWinName = "Video_Origin";
-
-
- cvNamedWindow(originVideoWinName.c_str(),CV_WINDOW_AUTOSIZE);
- while (1)
- {
- frame = cvQueryFrame(g_capture); // 捕獲每幀
- if (!frame)
- {
- break;
- }
- cvShowImage(originVideoWinName.c_str(),frame);
- char c = cvWaitKey(33);
- if (c==27)
- {
- break;
- }
- }
- cvReleaseCapture(&g_capture);
- cvDestroyWindow(originVideoWinName.c_str());
- }
Copyright ©
Linux教程網 All Rights Reserved