/* * File: pedestrian_safety_det.hpp * Created Date: Tuesday February 15th 2022 * Author: yangzilong (yangzilong@objecteye.com) * Description: * ----- * Last Modified: Tuesday, 15th February 2022 6:19:37 pm * Modified By: yangzilong (yangzilong@objecteye.com>) * ----- * Copyright 2022 */ #pragma once #include #include #include "include.h" #include "hat_callsmoke_vestuniform_det.h" #include "./strategies/mn_strategy.hpp" #define IMAGE_CROP_EXPAND_RATIO 0 namespace ai_engine_module { namespace pedestrian_safety_det { /** * @brief Single Stream Multi Algor shared detect result. * */ enum class label_t { PLACEHOLDER = -1, helmet = 0, smoke = 1, phone = 2, vest = 3, uniform = 4, suit = 5, }; using obj_key_to_mn_strategy_t = std::map>; typedef struct input_data_wrap_t { id_t objId; std::string taskId; box_t box; } input_data_wrap_t; #if 0 struct obj_key_t { obj_id_t obj_id; task_id_t task_id; algorithm_type_t algor_type; const bool operator<(const obj_key_t& obj) const { return obj_id < obj.obj_id || task_id < obj.task_id || static_cast(algor_type) < static_cast(obj.algor_type); } }; #endif typedef struct result_data_t { box_t box; sy_img ori_img; sy_img roi_img; obj_id_t obj_id; // as person_id. std::string task_id; std::set algorithm_type_seq; bool ori_img_is_in_gpu{ false }; bool roi_img_is_in_gpu{ false }; } result_data_t; using results_data_t = std::vector; class PedestrianSafetyDetector { /** * @brief * 1. move able */ public: PedestrianSafetyDetector(); ~PedestrianSafetyDetector(); bool is_support(const algorithm_type_t& algor_type) const noexcept; bool check_initied() const; bool init(const hat_callsmoke_vestuniform_det_param& initied_params); bool update_mstreams(const std::set& tasks_id, const sy_img* det_input_images, const std::vector & det_result); bool update_mstreams2(const std::vector& tasks_id, const sy_img* det_input_images, const std::vector & det_result); std::shared_ptr get_results_by_id(const unique_obj_id_t& id, bool do_erase = true); size_t get_number_of_results(); void force_release_result(const task_id_t& task_id); PedestrianSafetyDetector(const PedestrianSafetyDetector&) = delete; PedestrianSafetyDetector& operator=(const PedestrianSafetyDetector&) = delete; PedestrianSafetyDetector(PedestrianSafetyDetector&&) = default; PedestrianSafetyDetector& operator=(PedestrianSafetyDetector&&) = default; private: // static std::set algor_type_list_; unsigned batch_size_; bool initied_; void* handle_; task_param_manager* task_param_manager_; obj_key_to_mn_strategy_t obj_key_to_mn_strategy_; std::map id_to_results_; }; } // namespace pedestrian_safety_det } // namespace ai_engine_module