-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathTestFrameReader.cpp
51 lines (38 loc) · 1.14 KB
/
TestFrameReader.cpp
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
#include <iostream>
#include <string>
#include "FrameReader.hpp"
#include <opencv2/core/core_c.h>
#include <opencv2/highgui/highgui_c.h>
using namespace std;
int main(int argc, char **argv){
if (argc < 2){
cout << "not enough args" << endl;
exit(0);
}
int pixfmt = PIX_FMT_YUVJ420P;
string filename = argv[1];
cout << "file: " << filename << endl;
FrameReader *pReader = new FrameReader(filename, pixfmt);
int width, height;
pReader->GetSize(width, height);
cout << "Size: " << width << "x" << height << endl;
int64_t total;
pReader->GetNumberFrames(total);
cout << "Number frames: " << total << endl;
int64_t current = 0;
AVFrame *pframe;
cvNamedWindow("clipreader", CV_WINDOW_AUTOSIZE);
IplImage *img = cvCreateImageHeader(cvSize(width, height), IPL_DEPTH_8U, 1);
do {
pframe = pReader->GetFrame(current);
cvSetData(img, pframe->data[0], pframe->linesize[0]);
cvShowImage("clipreader", img);
cvWaitKey(10);
current++;
} while (current < total);
cout << "Done." << endl;
pReader->~FrameReader();
cout << "Done." << endl;
cvDestroyAllWindows();
return 0;
}