Repository navigation
Expand file tree
/
Copy pathmain.cpp
More file actions
71 lines (57 loc) · 1.8 KB
/
Copy pathmain.cpp
File metadata and controls
71 lines (57 loc) · 1.8 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
#include "NavigationDetection/navigation_detection.h"
#include "PositionEstimation/position_estimation.h"
#include "ObjectDetection/object_detection.h"
#include "shared_data.h"
#include "ACC/acc.h"
#include "utils.h"
#include "AR/ar.h"
#include <future>
#include <memory>
#include <thread>
int main() {
SharedData shared_data;
NavigationDetection navigation_detection(shared_data);
std::promise<std::shared_ptr<AR>> ar_ready;
auto ar_future = ar_ready.get_future();
std::thread ar_thread([ar_ready = std::move(ar_ready)]() mutable {
auto ar = std::make_shared<AR>(
std::bind(
utils::find_window,
std::wstring(L"Truck Simulator"),
std::vector<std::wstring>{L"Discord"}
)
);
ar_ready.set_value(ar);
utils::Timer timer;
while (true) {
ar->run();
timer.limit_fps(120.0f);
}
});
ar_thread.detach();
auto ar = ar_future.get();
std::thread position_estimation_thread([ar, &shared_data]() {
PositionEstimation position_estimation(ar.get(), shared_data);
ObjectDetector object_detector(ObjectDetectionDevice::DirectML, 1);
utils::Timer timer;
while (true) {
auto detections = object_detector.run();
position_estimation.run(
detections,
object_detector.window_width,
object_detector.window_height
);
auto fps = timer.get_fps();
printf("PositionEstimation FPS: %.2f\n", fps);
}
});
position_estimation_thread.detach();
ACC acc(shared_data);
utils::Timer timer;
while (true) {
navigation_detection.update();
acc.update();
timer.limit_fps(20.0f);
}
return 0;
}