Commit | Line | Data |
---|---|---|
80f575fc DM |
1 | |
2 | #include <string.h> | |
3 | #include <stdio.h> | |
4 | #include <limits.h> | |
5 | #include <math.h> | |
6 | #include <features.h> | |
7 | ||
8 | #ifdef USE_OMP | |
9 | #include <omp.h> | |
10 | #endif | |
11 | ||
12 | #include "libvidstab.h" | |
13 | // load optimized functions | |
14 | #include "motiondetect_internal.h" | |
15 | #include "motiondetect_opt.h" | |
16 | #include "boxblur.h" | |
17 | #include "transformfixedpoint.h" | |
18 | #include "transformfloat.h" | |
19 | #include "transformtype_operations.h" | |
20 | ||
21 | #ifndef TESTING | |
22 | #error TESTING must be defined | |
23 | #endif | |
24 | ||
25 | #include "testframework.h" | |
26 | #include "testutils.h" | |
27 | ||
28 | #include "generate.c" | |
29 | ||
30 | #include "test_transform.c" | |
31 | #include "test_compareimg.c" | |
32 | #include "test_motiondetect.c" | |
33 | #include "test_store_restore.c" | |
34 | #include "test_contrast.c" | |
35 | #include "test_boxblur.c" | |
36 | #include "test_omp.c" | |
37 | #include "test_gradientoptimizer.c" | |
38 | #include "test_localmotion2transform.c" | |
39 | ||
40 | #define FRAMENUM 5 | |
41 | ||
42 | int main(int argc, char** argv){ | |
43 | ||
44 | if(contains(argv,argc,"-h", "help")!=0){ | |
45 | printf("Usage: %s [--store --load] [--all| --testX ...]\n", argv[0]); | |
46 | unittest_help_mode(); | |
47 | } | |
48 | ||
49 | unittest_init(); | |
50 | ||
51 | int all = contains(argv,argc,"--all", "Perform all tests")!=0; | |
52 | ||
53 | TestData testdata; | |
54 | vsFrameInfoInit(&testdata.fi,1280, 720, PF_YUV420P); | |
55 | vsFrameInfoInit(&testdata.fi_color, 640, 360, PF_GRAY8); | |
56 | ||
57 | if(contains(argv,argc,"--load", | |
58 | "Load frames from files from frames/frame001.raw (def: generate)")!=0){ | |
59 | FILE* file; | |
60 | char name[128]; | |
61 | int i; | |
62 | for(i=0; i<FRAMENUM; i++){ | |
63 | vsFrameAllocate(&testdata.frames[i],&testdata.fi); | |
64 | sprintf(name,"../frames/frame%03i.raw",i+4); | |
65 | fprintf(stderr, "load file %s\n", name); | |
66 | file = fopen(name,"rb"); | |
67 | test_bool(file!=0); | |
68 | fprintf(stderr,"read %li bytes\n", | |
69 | (unsigned long)fread(testdata.frames[i].data[0], 1, | |
70 | testdata.fi.width*testdata.fi.height,file)); | |
71 | fclose(file); | |
72 | } | |
73 | }else{ | |
74 | UNIT(generateFrames(&testdata, FRAMENUM)); | |
75 | } | |
76 | if(contains(argv,argc,"--store", "Store frames to files")!=0){ | |
77 | storePGMImage("test1.pgm", testdata.frames[0].data[0], testdata.fi); | |
78 | storePGMImage("test2.pgm", testdata.frames[1].data[0], testdata.fi); | |
79 | storePGMImage("test3.pgm", testdata.frames[2].data[0], testdata.fi); | |
80 | storePGMImage("test4.pgm", testdata.frames[3].data[0], testdata.fi); | |
81 | storePGMImage("test5.pgm", testdata.frames[4].data[0], testdata.fi); | |
82 | } | |
83 | ||
84 | #ifdef USE_OMP | |
85 | openmp(); | |
86 | #endif | |
87 | ||
88 | if(all || contains(argv,argc,"--testTI", "transform_implementation")){ | |
89 | UNIT(test_transform_implementation(&testdata)); | |
90 | } | |
91 | ||
92 | if(all || contains(argv,argc,"--testTP", "transform_performance")){ | |
93 | UNIT(test_transform_performance(&testdata)); | |
94 | } | |
95 | ||
96 | if(all || contains(argv,argc,"--testBB", "boxblur")){ | |
97 | UNIT(test_boxblur(&testdata)); | |
98 | } | |
99 | ||
100 | if(all || contains(argv,argc,"--testCCI", "checkCompareImg")){ | |
101 | UNIT(test_checkCompareImg(&testdata)); | |
102 | } | |
103 | ||
104 | if(all || contains(argv,argc,"--testCIP", "compareImg_performance")){ | |
105 | UNIT(test_compareImg_performance(&testdata)); | |
106 | } | |
107 | ||
108 | if(all || contains(argv,argc,"--testMD", "motionDetect")){ | |
109 | UNIT(test_motionDetect(&testdata)); | |
110 | } | |
111 | ||
112 | if(all || contains(argv,argc,"--testLM", "localmotion2transform")){ | |
113 | UNIT(test_localmotion2transform(&testdata)); | |
114 | } | |
115 | ||
116 | if(all || contains(argv,argc,"--testSR", "store_restore")){ | |
117 | UNIT(test_store_restore(&testdata)); | |
118 | } | |
119 | ||
120 | if(all || contains(argv,argc,"--testCT", "contrastImg")){ | |
121 | UNIT(test_contrastImg(&testdata)); | |
122 | } | |
123 | ||
124 | if(all || contains(argv,argc,"--testGO", "gradient optimizer")){ | |
125 | UNIT(test_gradientoptimizer()); | |
126 | } | |
127 | ||
128 | // free | |
129 | for(int i=0; i<FRAMENUM; i++) | |
130 | vsFrameFree(&testdata.frames[i]); | |
131 | ||
132 | return unittest_summary(); | |
133 | } |