-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBackR.cpp
More file actions
54 lines (47 loc) · 1.07 KB
/
Copy pathBackR.cpp
File metadata and controls
54 lines (47 loc) · 1.07 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
#include "TaskManager.h"
#include "FaceDetector.h"
#include <iostream>
#include <string>
#include <chrono>
#include <thread>
#include <stdexcept>
int main(int argc, char* argv[])
{
if (argc != 3)
{
std::cout << "Usage: " << argv[0]
<< " [database user] [database password] " << std::endl;
return 1;
}
try
{
StalkR::TaskManager manager("stalkr", "localhost", argv[1], argv[2]);
StalkR::FaceDetector detector("haarcascade_frontalface_alt.xml");
std::cout << "BackR started" << std::endl;
for (;;)
{
try
{
manager.fetchTasks();
manager.executeTasks(&detector);
manager.clearTasks();
}
catch(const std::runtime_error &e)
{
// Hope it was a fluke. Report the error,
// clear the state and try again.
std::cerr << e.what() << std::endl;
manager.clearTasks();
}
// Avoid busy waiting if we have no tasks.
std::this_thread::sleep_for(std::chrono::seconds(1));
}
}
catch(const std::exception &e)
{
// Unexpected exception, bail.
std::cerr << e.what() << std::endl;
return 1;
}
return 0;
}