-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
61 lines (45 loc) · 1.49 KB
/
main.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
61
#include <memory>
#include <signal.h>
#include <opencv2/opencv.hpp>
#include "spdlog/spdlog.h"
#include "spdlog/sinks/ansicolor_sink.h"
#include "spdlog/sinks/basic_file_sink.h"
#include "RapidReactVision.h"
#include "Setup.h"
// Sigint Handler
void sigint_handler(int signal);
// Vision processor
std::unique_ptr<Lightning::RapidReactVision> vision;
// Logger - create sinks here so they can be shared with main and processors
std::vector<spdlog::sink_ptr> sinks {
std::make_shared<spdlog::sinks::ansicolor_stdout_sink_mt>(),
std::make_shared<spdlog::sinks::basic_file_sink_mt>("DeepSpaceVision.log")
};
std::shared_ptr<spdlog::logger> logger;
int main(int, char**) {
// Register Ctrl-C Handler
signal(SIGINT, sigint_handler);
// Setup
Lightning::Setup::LoadSetup();
// Logger
logger = std::make_shared<spdlog::logger>("Main", sinks.begin(), sinks.end());
logger->set_level(Lightning::Setup::Diagnostics::LogLevel);
// Vision Processors
vision = std::make_unique<Lightning::RapidReactVision>(sinks);
logger->debug("Starting DeepSpaceVision");
if (!vision->StartProcessing())
{
logger->error("Failed to start DeepSpaceVision");;
}
while (vision->IsProcessRunning())
{
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
logger->debug("DeepSpaceVision has stopped.");
return 0;
}
void sigint_handler(int signal)
{
logger->debug("sigint_handler: {0}", signal);
vision->StopProcessing();
}