-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVideoFrameGetter.cpp
More file actions
56 lines (54 loc) · 1.24 KB
/
VideoFrameGetter.cpp
File metadata and controls
56 lines (54 loc) · 1.24 KB
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
47
48
49
50
51
52
53
54
55
56
#include "VideoFrameGetter.h"
#include <QDir>
VideoFrameGetter::VideoFrameGetter(QString dir)
{
_frame=NULL;
_capture=NULL;
frame_count=0;
count=0;
directory_name=dir;
init();
}
void VideoFrameGetter::init()
{
QDir dir(directory_name);
if(dir.exists())
{
dir.setFilter(QDir::Files);
current_files=dir.entryInfoList();
}
if(current_files.size()>1)
{
current_file=current_files.first();
_capture=cvCaptureFromAVI(current_file.absoluteFilePath().toStdString().c_str());
}
}
int VideoFrameGetter::getCurrent_frame_count()
{
return frame_count;
}
QString VideoFrameGetter::getCurrent_frame_name()
{
return current_file.fileName();
}
void VideoFrameGetter::captureNextFrame()
{
if(_capture)
{
_frame=cvQueryFrame(_capture);
frame_count++;
if(_frame==NULL && current_files.size()>1)
{
current_files.removeFirst();
current_file=current_files.first();
_capture=cvCaptureFromAVI(current_file.absoluteFilePath().toStdString().c_str());
_frame=cvQueryFrame(_capture);
frame_count=0;
}
}
}
IplImage *VideoFrameGetter::getNextFrame()
{
captureNextFrame();
return _frame;
}