Blame view

src/ai_platform/MultiSourceProcess.h 7.79 KB
09c2d08c   Hu Chunming   arm交付版
1
2
3
4
5
6
7
8
9
10
11
12
13
14
  #include <map>
  #include <mutex>
  #include <thread>
  #include <list>
  #include <vector>
  #include <deque>
  #include <set>
  
  #include "header.h"
  #include "acl/acl.h"
  #include "acl/ops/acl_dvpp.h"
  #include "task_param_manager.h"
  #include "../reprocessing_module/snapshot_reprocessing.h"
  #include "../reprocessing_module/save_snapshot_reprocessing.h"
fa818303   Zhao Shuaihua   增加闯红灯功能(特定场景);优化货...
15
  #include "../ai_engine_module/ai_engine_module.h"
09c2d08c   Hu Chunming   arm交付版
16
  #include "../util/JpegUtil.h"
b309bd27   Zhao Shuaihua   通途版本增加授权
17
  #include "atlas_licence.h"//授权文件
09c2d08c   Hu Chunming   arm交付版
18
19
20
21
22
23
24
25
26
27
  
  #ifdef POST_USE_RABBITMQ
  #include "../reprocessing_module/mq_manager.hpp"
  #endif
  
  
  using namespace std;
  
  class DeviceMemory;
  
02e5e637   Zhao Shuaihua   增加行人/非机动车占机动车道(50...
28
29
30
31
32
33
34
35
36
  //分割信息
  typedef struct seg_infos {
  	bool isseg = false;    //是否分割
  	vector<vector<int>> traffic_region; //道路区域(多个)
    vector<int> labels; //道路区域对应的类别:机动车道、非机动车道等	
    vector<vector<int>> fence_region; //护栏区域(多个)
    vector<int> fence_labels; //护栏区域对应的类别:道路护栏、车道分割栏等				        
  } seg_infos;
  
09c2d08c   Hu Chunming   arm交付版
37
38
39
40
41
42
43
44
45
46
47
48
  class CMultiSourceProcess {
  public:
    CMultiSourceProcess();
    ~CMultiSourceProcess();
  
    int InitAlgorthim(tsl_aiplatform_param vptParam);
    bool AddTask(task_param _cur_task_param);
    bool PauseTask(const string taskID);
    bool RestartTask(const string taskID);
    bool FinishTask(const string taskID);
    void CloseAllTask();
    int SnapShot(task_param param);
b17e0e69   Zhao Shuaihua   闯红灯增加场景自适应、轨迹约束;逆...
49
50
51
    int CountRunningTask();
  
    void CloseAllTask2();
09c2d08c   Hu Chunming   arm交付版
52
53
54
55
56
57
58
59
60
61
62
  
  #ifdef POST_USE_RABBITMQ
    int AddMqConn(mq_type_t mq_type, rabbitmq_conn_params_t mq_conn_param);
    int GetTaskStatus(const string taskID);
  #endif
  
  public:
    int algorthim_process_thread();  // 算法处理线程
    void task_finished(const string task_id);
    void decoded_cbk(DeviceMemory* devFrame);
    void timing_snapshot_thread();
beec83ee   Hu Chunming   添加发送录制消息的线程
63
64
    // 发送录制消息给任务
    int recode_thread();
e0e42d5c   Zhao Shuaihua   添加时间限制:用于农村违法分析;修...
65
    bool CheckTime();
09c2d08c   Hu Chunming   arm交付版
66
67
68
69
70
71
72
73
74
75
76
  
  private:
    // 算法相关
    int algorthim_vpt(vector<DeviceMemory*> vec_gpuMem);
    // 人脸检测抓拍算法
    void algorthim_face_detect(vector<DeviceMemory*> vec_gpuMem);
    // 逆行
    void algorthim_retrograde(vector<string>& vpt_interest_task_id, vector<DeviceMemory*> vpt_interest_imgs, vector<onelevel_det_result>& vptResult);
    // 闯入
    void algorthim_trespass(vector<string>& vpt_interest_task_id, vector<DeviceMemory*> vpt_interest_imgs, 
                                                    vector<onelevel_det_result>& vptResult ,vector<vector<int>>& deleteObjectID);  
9c03cbe4   Zhao Shuaihua   增加三轮车/货车载人 二轮车超员/...
77
    
02e5e637   Zhao Shuaihua   增加行人/非机动车占机动车道(50...
78
79
80
81
    // 道路分割
    int algorthim_road_seg(vector<DeviceMemory*> vec_gpuMem);
    // 轨迹记录
    void trace_record(vector<string>& vpt_interest_task_id, vector<onelevel_det_result>& vptResult);
9c03cbe4   Zhao Shuaihua   增加三轮车/货车载人 二轮车超员/...
82
83
84
85
86
87
    // 三轮车载人
    void algorithm_tricycle_manned(vector<string>& vpt_interest_task_id, vector<DeviceMemory*> vpt_interest_imgs, vector<onelevel_det_result>& vptResult);
    // 货车载人
    void algorithm_truck_manned(vector<string>& vpt_interest_task_id, vector<DeviceMemory*> vpt_interest_imgs, vector<onelevel_det_result>& vptResult);
    // 二轮车超员及未戴盔
    void algorithm_motor_hs_process(vector<string>& vpt_interest_task_id, vector<DeviceMemory*> vpt_interest_imgs, vector<onelevel_det_result>& vptResult);
5f4efeaa   Zhao Shuaihua   玩手机增加车辆朝向及雨棚过滤
88
89
    // 电动车改装(加雨棚)及二轮车驾乘人员使用手机
    void algorithm_motor_refit_phone_process(vector<string>& vpt_interest_task_id, vector<DeviceMemory*> vpt_interest_imgs, vector<onelevel_det_result>& vptResult);
c5fce6ce   Zhao Shuaihua   增加二轮车玩手机505、加装雨棚5...
90
91
92
93
    // 二轮车驾乘人员使用手机
    void algorithm_motor_phone_process(vector<string>& vpt_interest_task_id, vector<DeviceMemory*> vpt_interest_imgs, vector<onelevel_det_result>& vptResult);
    // 电动车改装(加雨棚)
    void algorithm_motor_refit_process(vector<string>& vpt_interest_task_id, vector<DeviceMemory*> vpt_interest_imgs, vector<onelevel_det_result>& vptResult);
fa818303   Zhao Shuaihua   增加闯红灯功能(特定场景);优化货...
94
95
    // 行人/二轮车闯红灯
    void algorithm_traffic_light_process(vector<string>& vpt_interest_task_id, vector<DeviceMemory*> vpt_interest_imgs, vector<onelevel_det_result>& vptResult);
02e5e637   Zhao Shuaihua   增加行人/非机动车占机动车道(50...
96
97
    // 道路分割相关算法--占用机动车道等
    void algorithm_roadseg_correlation_process(vector<string>& vpt_interest_task_id, vector<DeviceMemory*> vpt_interest_imgs, vector<onelevel_det_result>& vptResult);
9c03cbe4   Zhao Shuaihua   增加三轮车/货车载人 二轮车超员/...
98
    
09c2d08c   Hu Chunming   arm交付版
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
  
  private:
    // 工具处理函数
    bool task_has_vpt_algor(const std::string &task_id);
    bool task_has_face_algor(const std::string &task_id);
    void clear_finished_task();
    bool finish_task(const string taskID, const bool delete_snapshot);
    int algorithm_vehicle_relult(vector<DeviceMemory*> vec_devMem, vector<onelevel_det_result>& vptResult, vector<vector<int>>& delete_object_id);
    void send_locus_finished_msg(vector<string>& vpt_interest_task_id, vector<vector<int>> deleteObjectID);
    void vehicle_snapshot(vector<string>& vpt_interest_task_id, vector<vector<int>> deleteObjectID);
    void vehicle_locus_finished(const OBJ_KEY obj_key);
  
    bool save_snapshot_process(const OBJ_KEY &obj_key, const algorithm_type_t &algorithm_type, vpc_img_info img_info,  vpc_img_info roi_img,
                                         const long long id,const std::string &json_str);
  
    void retrograde_snapshot(vector<string>& vpt_interest_task_id, vector<vector<int>> deleteObjectID);
    void trespass_snapshot(vector<string>& vpt_interest_task_id, vector<vector<int>> deleteObjectID);
9c03cbe4   Zhao Shuaihua   增加三轮车/货车载人 二轮车超员/...
116
117
    void void retrograde_trespass_alarm(const OBJ_KEY &obj_key, const algorithm_type_t &algor_type) ;(const OBJ_KEY &obj_key, const algorithm_type_t &algor_type) void retrograde_trespass_alarm(const OBJ_KEY &obj_key, const algorithm_type_t &algor_type) ; 
    //  village
c5fce6ce   Zhao Shuaihua   增加二轮车玩手机505、加装雨棚5...
118
    void village_snapshot(vector<string>& vpt_interest_task_id, vector<DeviceMemory*> vec_vptMem, vector<vector<int>> deleteObjectID);
9c03cbe4   Zhao Shuaihua   增加三轮车/货车载人 二轮车超员/...
119
   
09c2d08c   Hu Chunming   arm交付版
120
121
122
123
124
125
126
127
128
129
130
131
132
133
  
    void face_locus_finished(const OBJ_KEY obj_key);
  
    int snapshot_task(std::string& uri_or_name, const std::string& file_name, bool bInTask);
  private:
    int m_devId; 
  
    snapshot_reprocessing *m_snapshot_reprocessing{nullptr};
    task_param_manager *m_task_param_manager{nullptr};
    save_snapshot_reprocessing *m_save_snapshot_reprocessing{nullptr};
  
    std::thread* m_timing_snapshot_thread;
  
    VPTProcess vpt_process;
02e5e637   Zhao Shuaihua   增加行人/非机动车占机动车道(50...
134
135
    RoadSegProcess seg_process;
    Road3clsSegProcess seg3cls_process;
09c2d08c   Hu Chunming   arm交付版
136
137
138
139
140
141
142
143
    int skip_frame_ = 5; // 控制跳帧参数
  
    deque<DeviceMemory*> m_RgbDataList;
    mutex m_DataListMtx; 
  
    mutex m_FinishedTaskMtx;
    map<string,bool> m_FinishedTaskMap;
  
0683ce86   Zhao Shuaihua   调整jni;主动删除的任务不推送mq
144
145
146
    mutex m_ActiveFinishedTaskMtx ;
    map<string,bool> m_ActiveFinishedTaskMap; // 记录主动结束的任务,不发送mq
  
02e5e637   Zhao Shuaihua   增加行人/非机动车占机动车道(50...
147
148
149
150
151
152
    mutex m_RoadSegTaskMtx ;
    map<string,seg_infos> m_RoadSegTaskMap;   // 记录道路分割相关信息
  
    mutex m_TotalObjMtx ;
    map<OBJ_KEY, OBJ_INDEX> m_total_obj_info; // 记录目标轨迹
  
09c2d08c   Hu Chunming   arm交付版
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
    thread* m_pAlgorthimThread;
    bool m_bfinish{false};
  
    int m_batch_size{1};
  
    set<OBJ_KEY> m_total_snapshot_info_multi_object;
    mutex m_total_mutex;
  
  #ifdef POST_USE_RABBITMQ
    mq::Manager *mq_manager_{nullptr};
  #endif
  
  
    ai_engine_module::pedestrian_vehicle_retrograde::PedestrianVehicleRetrograde pedestrian_vehicle_retrograde_;
    ai_engine_module::pedestrian_vehicle_trespass::PedestrianVehicleTrespass pedestrian_vehicle_trespass_;
9c03cbe4   Zhao Shuaihua   增加三轮车/货车载人 二轮车超员/...
168
169
170
    ai_engine_module::tricycle_manned_process::TricycleMannedProcess tricycle_manned_;
    ai_engine_module::truck_manned_process::TruckMannedProcess truck_manned_;
    ai_engine_module::motocycle_hs_process::MotorHsProcess motor_hsprocess_;
5f4efeaa   Zhao Shuaihua   玩手机增加车辆朝向及雨棚过滤
171
172
    ai_engine_module::motocycle_refit_phone_process::MotorRefitPhoneProcess motor_refit_phoneprocess_;
    // ai_engine_module::motocycle_phone_process::MotorPhoneProcess motor_phoneprocess_;
b5aaf53a   Zhao Shuaihua   雨棚模型升级
173
    ai_engine_module::motocycle_refit_process::MotorRefitProcess motor_refitprocess_;
fa818303   Zhao Shuaihua   增加闯红灯功能(特定场景);优化货...
174
    ai_engine_module::traffic_light_process::TrafficLightProcess traffic_lightprocess_;
02e5e637   Zhao Shuaihua   增加行人/非机动车占机动车道(50...
175
    ai_engine_module::road_seg_correlation_process::RoadSegCorrelation roadseg_corrprocess_;
09c2d08c   Hu Chunming   arm交付版
176
177
178
  
    face_det_ai_engine m_face_det_ai_engine; // 人脸检测
  
beec83ee   Hu Chunming   添加发送录制消息的线程
179
180
181
182
    deque<RecoderInfo> m_recoderinfo_queue;
    mutex m_recoderinfo_queue_mtx;
    thread* m_recode_thread {nullptr};
  
b309bd27   Zhao Shuaihua   通途版本增加授权
183
184
185
186
    void *skt_handle = nullptr;//授权
  	atlas_licence_check_param check_param;//授权
  	int check_label = -1;//授权 -1=未授权  0=授权  1=授权check日已经check成功(每月一次check
  
9c03cbe4   Zhao Shuaihua   增加三轮车/货车载人 二轮车超员/...
187
  
09c2d08c   Hu Chunming   arm交付版
188
  };