-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest.cpp
More file actions
106 lines (97 loc) · 3.2 KB
/
test.cpp
File metadata and controls
106 lines (97 loc) · 3.2 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
#include <map>
#include "log_system.h"
using namespace std;
using namespace logsystem;
using namespace cv;
void help(const std::map<string, int>& order_map)
{
cout << "you can put in ";
for(auto order : order_map){
cout << "\"" << order.first << "\" ";
}
cout << "to execute relative order" << endl;
}
int main(int argc, char** argv) try
{
string order;
string n, p, pho;
Mat img;
int i_order;
LogSystem um;
int result = 0;
cv::namedWindow("window", CV_WINDOW_AUTOSIZE);
std::map<string, int> order_map;
order_map["su"] = 1;
order_map["fsi"] = 2;
order_map["q"] = 3;
order_map["who"] = 4;
order_map["so"] = 5;
order_map["psi"] = 6;
order_map["da"] = 7;
help(order_map);
while(1){
getline(std::cin, order);
auto om_find = order_map.find(order);
if(om_find == order_map.end())
i_order = 0;
else
i_order = om_find->second;
switch(i_order){
case 1://signup
cout << "Please enter name!" << endl;
getline(std::cin, n);
cout << "Please enter password!" << endl;
getline(std::cin, p);
cout << "Please enter photo path!" << endl;
getline(std::cin, pho);
img = imread(pho);
if(img.empty()){
cout << "invalid photo" << endl;
break;
}
cv::imshow("window", img);
result = um.signUp(n, img, p);
cout << "sign up result is: " << result << endl;
break;
case 2://facesignin
cout << "Please enter photo path!" << endl;
getline(std::cin, pho);
img = imread(pho);
if(img.empty()){
cout << "invalid photo" << endl;
break;
}
cv::imshow("window", img);
result = um.signInByFace(img);
cout << "sign in result is: " << result << ". means: " << um.getCurrentUserName() << endl;
break;
case 3://quit
return 0;
case 4://who
cout << "current user is: " << um.getCurrentUserName() << endl;
break;
case 5://sign out
um.signOut();
break;
case 6://password sign in
cout << "Please enter name!" << endl;
getline(std::cin, n);
cout << "Please enter password!" << endl;
getline(std::cin, p);
result = um.signInByPassword(n, p);
cout << "sign in result is: " << result << ". means: " << um.getCurrentUserName() << endl;
break;
case 7://delete account
cout << "If you are sure to delete your account, please end \"ok\"" << endl;
getline(std::cin, n);
if(n == "ok")
um.deleteAccount();
break;
default:
help(order_map);
}
}
return 0;
}catch (std::exception& e){
cout << e.what() << endl;
}