pedestrian_safety_det.hpp
3.63 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
/*
* 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 <map>
#include <vector>
#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<obj_key_t, MNStrategy<label_t>>;
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<int>(algor_type) < static_cast<int>(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_t> 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<result_data_t>;
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<task_id_t>& tasks_id,
const sy_img* det_input_images,
const std::vector <onelevel_det_result>& det_result);
bool update_mstreams2(const std::vector<task_id_t>& tasks_id, const sy_img* det_input_images, const std::vector <onelevel_det_result>& det_result);
std::shared_ptr <results_data_t> 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<algorithm_type_t> 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 <unique_obj_id_t, results_data_t> id_to_results_;
};
} // namespace pedestrian_safety_det
} // namespace ai_engine_module