traffic_light_process.h
4.67 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#pragma once
#include <deque>
#include <map>
#include <vector>
#include <memory>
#include "../util/vpc_util.h"
#include "../ai_platform/task_param_manager.h"
#include "../ai_platform/macro_definition.h"
#include "ai_engine_header.h"
#include "traffic_light_det.h"
#include "acl/acl.h"
#include "acl/ops/acl_dvpp.h"
#define MAX_BATCH 20
#define IMAGE_CROP_EXPAND_RATIO 0
#define MAX_OBJ_BOX_COUNT 100
#define MAX_LANE_NUM 100
#define PRECISION 1e-8
#define Pi 3.14159265358979
namespace ai_engine_module
{
namespace traffic_light_process
{
// typedef long id_t;
using id_t = obj_key_t;
using task_id_t = std::string;
using algor_param_type = algor_config_param_manned_incident*;
enum class label_t {
PLACEHOLDER = -1,
red = 0, //直行红灯
green = 1, //直行绿灯
yellow = 2, //直行黄灯
wred = 3, //转向红灯
wgreen = 4, //转向绿灯
wyellow = 5, //转向黄灯
pred = 6, //行人红灯
pyellow = 7, //行人黄灯
pgreen = 8, //行人绿灯
bred = 9, //自行车红灯
byellow = 10, //自行车黄灯
bgreen = 11, //自行车绿灯
no = 12, //灭灯
};
enum class seg_label_t {
PLACEHOLDER = -1,
background = 0, //背景
vehicle_lanes = 1, //机动车道
nonvehicle_lanes = 2, //非机动车道
emerg_lanes = 3, //应急车道
guide_line = 4, //导流线
crosswalk = 5, //人行横道
no_parking_area = 6, //禁停区域
interestion_area = 7, //十字路口区域
yellow_solidline = 8, //黄实线
white_solidline = 9, //白实线
white_dottedline = 10, //虚线
yellow_dottedline = 11, //黄虚线
};
typedef struct input_data_wrap_t
{
id_t id;
long objId;
std::string taskId;
box_t box;
} input_data_wrap_t;
typedef struct tr_point {
float x, y;
}tr_point;
typedef struct mn_frame_t
{
uint m_frame;
uint n_frame;
// explicit
mn_frame_t(uint m = 0, uint n = 0)
: m_frame(m)
, n_frame(n)
{}
void reset()
{
m_frame = 0;
n_frame = 0;
}
} mn_frame_t;
typedef struct results_data_t
{
box_t box;
acldvppPicDesc* origin_img_desc{nullptr};
acldvppPicDesc* roi_img_desc{nullptr};
id_t id;
long objId;
std::string taskId;
algorithm_type_t algor_type;
} results_data_t;
class TrafficLightProcess
{
/**
* @brief
* 1. move able
*/
public:
TrafficLightProcess();
~TrafficLightProcess();
bool check_initied();
bool init(int gpu_id, string models_dir);
// bool update_mstreams(const std::vector<task_id_t>& taskIds, vector<sy_img> src_interest_imgs, vector<DeviceMemory*> vec_det_input_images, const std::vector<onelevel_det_result> &det_results);
bool update_mstreams(const std::vector<task_id_t>& taskIds, vector<sy_img> src_interest_imgs, vector<DeviceMemory*> vec_det_input_images, const vector<vector<vector<int>>>& traffic_region, const vector<vector<int>>& labels, map<OBJ_KEY, OBJ_INDEX> &m_total_obj_info, const std::vector<onelevel_det_result> &det_results);
std::shared_ptr<results_data_t> get_result_by_objectid(const id_t& id, bool do_erase = true);
void force_release_result(const task_id_t& task_id);
TrafficLightProcess(const TrafficLightProcess&) = delete;
TrafficLightProcess& operator=(const TrafficLightProcess&) = delete;
private:
static algorithm_type_t algor_type_;
int m_devId;
aclrtContext m_algorthim_ctx;
bool init_;
void* tools_;
task_param_manager* task_param_manager_;
std::map<id_t, mn_frame_t> id_to_mn_;
std::map<id_t, results_data_t> id_to_result_;
};
} // namespace traffic_light_process
} // namespace ai_engine_module