-
Notifications
You must be signed in to change notification settings - Fork 0
/
videomatch.cpp
60 lines (53 loc) · 1.47 KB
/
videomatch.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
57
58
59
60
#include "vm_log.h"
#include "vm_option_cv.h"
#include "vm_option_ff.h"
#include "vm_match_cv.h"
#include "vm_match_ff.h"
#include "vm_type.h"
#include "vm_output.h"
#include <functional>
#include <chrono>
int main(int argc, char* argv[]){
// get options
std::vector<std::string> args(argv, argv + argc);
codec_type codec = codec_type::ffmpeg;
for(int i = 0; i < args.size(); ++i){
if(args[i]=="-c" || args[i]=="-codec"){
if(args[i+1]=="ff" || args[i+1]=="ffmpeg"){
codec = codec_type::ffmpeg;
break;
}
if(args[i+1]=="cv" || args[i+1]=="opencv"){
codec = codec_type::opencv;
break;
}
}
}
std::function<void(std::vector<std::string>&)> get_option;
std::function<void()> do_match;
bool* benchmark = nullptr;
switch(codec){
case codec_type::ffmpeg:
get_option = vm_option_ff::get_option;
benchmark = &vm_option_ff::benchmark;
do_match = vm_match_ff::do_match;
break;
case codec_type::opencv:
get_option = vm_option_cv::get_option;
benchmark = &vm_option_cv::benchmark;
do_match = vm_match_cv::do_match;
break;
}
get_option(args);
// benchmark start
std::chrono::steady_clock::time_point start_time;
if(*benchmark)
start_time = std::chrono::high_resolution_clock::now();
// match
do_match();
// output
vm_output::vm_output(codec);
// benchmark end
if(*benchmark)
vm_log::info(std::format("benchmark {0}", std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now()-start_time)));
}