-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
82 lines (70 loc) · 1.68 KB
/
main.cpp
File metadata and controls
82 lines (70 loc) · 1.68 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
//
// Created by flyingtiger on 19-03-04.
//
#include <thread>
#include "MVCamera.h"
#include "RemoteControl.h"
#include "RoboMasterProcess.h"
#include "setting.h"
#include "uart.h"
/*
definitions:
__SHOW_DEBUGINFO__
__SHOWING_SRC_IMG__
__SHOWING_ALL_IMG__
__SAVE_VIDEO__
__READ_VIDEO__
*/
const char *VIDEOPATH = "../../../../test_video.avi";
using namespace std;
using namespace cv;
bool RUNNING = true;
inline void start_camera() {
#ifdef __SHOW_DEBUGINFO__
printf("MVCamera Init\n");
#endif
MVCamera::Init();
MVCamera::Play();
MVCamera::SetExposureTime(false, 2000);
MVCamera::SetLargeResolution(true);
}
#ifdef __READ_VIDEO__
int getframe_video(Mat &img) {
static VideoCapture cap(VIDEOPATH);
cap >> img;
return 0;
}
#endif
inline void stop_camera() {
MVCamera::Stop();
MVCamera::Uninit();
}
int main(int argc, char *argv[]) {
Setting setting;
setting.mode = 0; // 0:not working; 1:auto-shooooot
setting.color = 1; // 0: all 1: red 2: blue
#ifndef __READ_VIDEO__
start_camera();
#endif
// CAN commun("can0");
// UART commun("/dev/ttyUSB0", "/dev/ttyUSB1");
COMMUNICATOR commun;
// receive car command
RemoteControl remoteProcess(&setting, commun);
std::thread t0(&RemoteControl::Receiver, &remoteProcess);
// process frame and send angle to car
#ifndef __READ_VIDEO__
RoboMasterProcess roboProcess(&setting, commun, &MVCamera::GetFrame);
#else
RoboMasterProcess roboProcess(&setting, commun, &getframe_video);
#endif
std::thread t1(&RoboMasterProcess::Process, &roboProcess);
t1.join();
RUNNING = false;
t0.join();
#ifndef __READ_VIDEO__
stop_camera();
#endif
std::cout << "Hello, World!" << std::endl;
return 0;
}