#pragma once #include #include #include #include #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 16 #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& taskIds, vector src_interest_imgs, vector vec_det_input_images, const std::vector &det_results); bool update_mstreams(const std::vector& taskIds, vector src_interest_imgs, vector vec_det_input_images, const vector>>& traffic_region, const vector>& labels, map &m_total_obj_info, const std::vector &det_results); std::shared_ptr 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_to_mn_; std::map id_to_result_; }; } // namespace traffic_light_process } // namespace ai_engine_module