-
Notifications
You must be signed in to change notification settings - Fork 8
/
Main.cpp
56 lines (47 loc) · 1.17 KB
/
Main.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
52
53
54
55
56
#include <opencv2/core/utility.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include "timer.hpp"
#include "mjpegwriter.hpp"
using namespace cv;
using namespace std;
#define TEST_MY 1
int main(int, char**)
{
Rect rect(0, 0, 1920, 1080);
Mat img(rect.size(), CV_8UC3);
img = imread("1920x1080.jpg");
img.size();
int nframes = 10;
jcodec::MjpegWriter * j = new jcodec::MjpegWriter();
VideoWriter outputVideo;
timer tt;
tt.start();
double ttotal = 0;
#if TEST_MY
j->Open("out.avi", (uchar)10, img.size());
#else
outputVideo.open("out2.avi", outputVideo.fourcc('M', 'J', 'P', 'G'), 10.0, img.size(), true);
#endif
for (int i = 0; i < nframes; i++)
{
double tstart = (double)getTickCount();
#if TEST_MY
j->Write(img);
#else
outputVideo.write(img);
#endif
double tend = (double)getTickCount();
ttotal += tend - tstart;
putchar('.');
fflush(stdout);
}
#if TEST_MY
j->Close();
#else
outputVideo.release();
#endif
tt.stop();
printf("time per frame (including file i/o)=%.1fms\n", (double)tt.get_elapsed_ms()/nframes);
return 0;
}