-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cc
More file actions
126 lines (106 loc) · 2.67 KB
/
main.cc
File metadata and controls
126 lines (106 loc) · 2.67 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#include "base_method.h"
#include "simple_method.h"
#include "assembling_method.h"
#include "linear_combination_method.h"
#include "normal_method.h"
#include "c_method.h"
#include "timer.h"
#include "search_database.h"
#include "experiment_manager.h"
#include <memory>
#include <iostream>
#define ENABLE_EXPERIMENT_MANAGER
namespace {
std::string methods[] = {
"Base", "Simple", "Linear combination", "Assembling", "Normal dot"
};
const int methodsN = 5;
std::string querys[] = {
kImageDir + "/circle_0.jpg",
kImageDir + "/caltech101/ant/image_0001.jpg"
};
const int querysN = 2;
void set_query(std::string& s) {
for (int i = 0; i < querysN; ++i)
printf("%d : %s\n", i, querys[i].c_str());
int input;
do {
fscanf(stdin, " %d", &input);
if (input < 0 || 1 < input) {
printf("input is %d!\n", input);
continue;
}
break;
} while (1);
s = querys[input];
}
}; // anonymous namespace
int main(int argc, char **argv) {
// データベースを初期化
SearchDatabase::init();
#ifdef ENABLE_EXPERIMENT_MANAGER
ExperimentManager exp(1);
exp.run();
return 0;
#else
for (;;) {
// 終了フラグ変数
bool flag = false;
// 時間計測
// もともとは Timer クラスのオブジェクト使ってたけど
// バグ出てたので、そのうち書きなおす
// static メソッドにすればいいのかもしれない
clock_t begin = clock();
std::string query;
puts("set query");
set_query(query);
puts("input method type [0-4]");
for (int i = 0; i < methodsN; ++i)
printf("%d : %s\n", i, methods[i].c_str());
char in;
if (scanf(" %c", &in) == -1) assert(false);
switch (in) {
case '0': {
BaseMethod base_method(query);
base_method.run();
break;
}
case '1': {
SimpleMethod simple_method(query);
simple_method.run();
break;
}
case '2': {
LinearCombinationMethod linear_combination_method(query);
linear_combination_method.run();
break;
}
case '3': {
AssemblingMethod assembling_method(query, 20, 50);
assembling_method.run();
break;
}
case '4': {
NormalMethod normal_method(query);
normal_method.run();
break;
}
case '5': {
CMethod c_method(query, 100, 50);
c_method.run();
break;
}
case 'q': {
flag = true;
break;
}
}
// time
printf("process : %f\n",
static_cast<double>(clock() - begin) / CLOCKS_PER_SEC);
// 終了フラグ
if (flag) break;
}
return 0;
#endif // ENABLE_EXPERIMENT_MANAGER
}