opencv 提取视频帧
利用opencv函数提取视频的帧。
1 #include"cv.h"
2 #include"highgui.h"
3 #include<stdio.h>
4
5
6
7 void capture_frame(){
8
9 char FileName[80];
10 memset(FileName,0,sizeof FileName);
11 CvCapture* capture = cvCaptureFromAVI("D:\\frame_capture\\data\\R0014063.AVI");
12 IplImage* img = 0;
13 int i;
14
15 i = 0;
16
17 while(cvGrabFrame(capture)){
18 img=cvRetrieveFrame(capture); // retrieve the captured frame
19 sprintf(FileName,"D:\\frame_capture\\data\\%04d.jpg",i);
20 cvSaveImage(FileName,img);
21 i++;
22 }
23
24
25 cvReleaseCapture(&capture);
26 }
27
28
29 void main(){
30
31 capture_frame();
32
33 }
2 #include"highgui.h"
3 #include<stdio.h>
4
5
6
7 void capture_frame(){
8
9 char FileName[80];
10 memset(FileName,0,sizeof FileName);
11 CvCapture* capture = cvCaptureFromAVI("D:\\frame_capture\\data\\R0014063.AVI");
12 IplImage* img = 0;
13 int i;
14
15 i = 0;
16
17 while(cvGrabFrame(capture)){
18 img=cvRetrieveFrame(capture); // retrieve the captured frame
19 sprintf(FileName,"D:\\frame_capture\\data\\%04d.jpg",i);
20 cvSaveImage(FileName,img);
21 i++;
22 }
23
24
25 cvReleaseCapture(&capture);
26 }
27
28
29 void main(){
30
31 capture_frame();
32
33 }
如果无法读取视频,请安装K-Lite Codec Pack解码器。
posted on 2010-11-29 16:55 Homography Matrix 阅读(3582) 评论(0) 编辑 收藏 举报