-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetFrames.cpp
More file actions
46 lines (37 loc) · 918 Bytes
/
Copy pathgetFrames.cpp
File metadata and controls
46 lines (37 loc) · 918 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "functions.h"
#include "errmsg.h"
extern long myErrno ;
IplImage** getFramesFromVideo(const char* fileName , int& size)
{
int numFrames = 0 ;
IplImage** frames = NULL ;
IplImage* tmp = NULL ;
CvCapture *capture = cvCaptureFromAVI(fileName) ;
size = 0 ;
if( !capture )
{
myErrno = ERR_OPEN_FILE ;
perrmsg("Can't open the file") ;
return NULL ;
}
cvQueryFrame(capture) ;
numFrames = (int)cvGetCaptureProperty(capture , CV_CAP_PROP_FRAME_COUNT) ;
frames = new IplImage*[numFrames+1] ;
while(cvGrabFrame(capture))
{
tmp = cvRetrieveFrame(capture) ;
frames[size++] = cvCloneImage(tmp);
}
cvReleaseCapture(&capture);
return frames ;
}
//int main(int argc, char *argv[])
//{
//int size = 0 ;
//IplImage** frames = getFramesFromVideo("1.avi" , size);
//cvNamedWindow("win");
//cvShowImage("win",frames[9]);
//P(size);
//cvWaitKey(0);
//releaseFrames(&frames , size);
//}