24 #include "modules/perception/camera/proto/yolo.pb.h" 34 namespace perception {
37 static const char NormalNMS[] =
"NormalNMS";
38 static const char LinearSoftNMS[] =
"LinearSoftNMS";
39 static const char GuassianSoftNMS[] =
"GuassianSoftNMS";
40 static const char BoxVote[] =
"BoxVote";
41 static const int kBoxBlockSize = 32;
42 static const int kMaxObjSize = 1000;
44 struct NormalizedBBox {
55 return i.score < j.score;
72 float inter_cls_nms_thresh;
73 float inter_cls_conf_thresh;
75 std::string type = BoxVote;
78 std::shared_ptr<base::Blob<float>> det1_loc_blob;
79 std::shared_ptr<base::Blob<float>> det1_obj_blob;
80 std::shared_ptr<base::Blob<float>> det1_cls_blob;
81 std::shared_ptr<base::Blob<float>> det1_ori_conf_blob;
82 std::shared_ptr<base::Blob<float>> det1_ori_blob;
83 std::shared_ptr<base::Blob<float>> det1_dim_blob;
84 std::shared_ptr<base::Blob<float>> det2_loc_blob;
85 std::shared_ptr<base::Blob<float>> det2_obj_blob;
86 std::shared_ptr<base::Blob<float>> det2_cls_blob;
87 std::shared_ptr<base::Blob<float>> det2_ori_conf_blob;
88 std::shared_ptr<base::Blob<float>> det2_ori_blob;
89 std::shared_ptr<base::Blob<float>> det2_dim_blob;
90 std::shared_ptr<base::Blob<float>> det3_loc_blob;
91 std::shared_ptr<base::Blob<float>> det3_obj_blob;
92 std::shared_ptr<base::Blob<float>> det3_cls_blob;
93 std::shared_ptr<base::Blob<float>> det3_ori_conf_blob;
94 std::shared_ptr<base::Blob<float>> det3_ori_blob;
95 std::shared_ptr<base::Blob<float>> det3_dim_blob;
97 std::shared_ptr<base::Blob<float>> lof_blob;
98 std::shared_ptr<base::Blob<float>> lor_blob;
99 std::shared_ptr<base::Blob<float>> brvis_blob;
100 std::shared_ptr<base::Blob<float>> brswt_blob;
101 std::shared_ptr<base::Blob<float>> ltvis_blob;
102 std::shared_ptr<base::Blob<float>> ltswt_blob;
103 std::shared_ptr<base::Blob<float>> rtvis_blob;
104 std::shared_ptr<base::Blob<float>> rtswt_blob;
105 std::shared_ptr<base::Blob<float>> area_id_blob;
106 std::shared_ptr<base::Blob<float>> visible_ratio_blob;
107 std::shared_ptr<base::Blob<float>> cut_off_ratio_blob;
108 std::shared_ptr<base::Blob<float>> res_box_blob;
109 std::shared_ptr<base::Blob<float>> res_cls_blob;
110 std::shared_ptr<base::Blob<float>> anchor_blob;
111 std::shared_ptr<base::Blob<float>> expand_blob;
114 float min_2d_height = 0.0f;
115 float min_3d_height = 0.0f;
116 float min_3d_length = 0.0f;
117 float min_3d_width = 0.0f;
127 const bool normalized);
131 template <
typename T>
133 const std::pair<float, T> &pair2) {
134 return pair1.first > pair2.first;
139 std::vector<std::pair<float, int>> *score_index_vec);
150 void apply_nms(
const bool *overlapped,
const int num,
151 std::vector<int> *indices);
153 void apply_nms_gpu(
const float *bbox_data,
const float *conf_data,
154 const std::vector<int> &origin_indices,
const int bbox_step,
155 const float confidence_threshold,
const int top_k,
156 const float nms_threshold, std::vector<int> *indices,
158 const cudaStream_t &_stream);
161 const float overlap_threshold,
162 const int *idx,
const int num_idx,
163 bool *overlapped_data,
164 const cudaStream_t &_stream);
167 const std::vector<base::ObjectSubType> &types,
168 const NMSParam &nms,
const yolo::ModelParam &model_param,
169 float light_vis_conf_threshold,
170 float light_swt_conf_threshold,
172 std::vector<base::ObjectPtr> *objects);
175 std::vector<float> *scores,
const float score_threshold,
176 const float nms_threshold,
const int top_k,
177 std::vector<int> *indices,
bool is_linear,
181 std::vector<float> *scores,
182 const float conf_threshold,
const float nms_threshold,
183 const float sigma, std::vector<int> *indices);
186 const std::vector<float> &scores,
187 const float score_threshold,
const float nms_threshold,
188 const float eta,
const int top_k,
189 std::vector<int> *indices);
192 std::vector<base::ObjectPtr> *objects);
195 std::vector<base::ObjectPtr> *objects);
void compute_overlapped_by_idx_gpu(const int nthreads, const float *bbox_data, const float overlap_threshold, const int *idx, const int num_idx, bool *overlapped_data, const cudaStream_t &_stream)
Definition: region_output.h:67
void apply_softnms_fast(const std::vector< NormalizedBBox > &bboxes, std::vector< float > *scores, const float score_threshold, const float nms_threshold, const int top_k, std::vector< int > *indices, bool is_linear, const float sigma)
bool operator()(NormalizedBBox i, NormalizedBBox j)
Definition: region_output.h:54
void filter_bbox(const SmokeMinDims &min_dims, std::vector< base::ObjectPtr > *objects)
int get_area_id(float visible_ratios[4])
void apply_nms(const bool *overlapped, const int num, std::vector< int > *indices)
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
void fill_frbox(bool with_frbox, base::ObjectPtr obj, const float *bbox)
float get_jaccard_overlap(const NormalizedBBox &bbox1, const NormalizedBBox &bbox2)
constexpr float minExpPower
Definition: region_output.h:121
Definition: region_output.h:71
Definition: region_output.h:114
constexpr int anchorSizeFactor
Definition: region_output.h:123
void apply_boxvoting_fast(std::vector< NormalizedBBox > *bboxes, std::vector< float > *scores, const float conf_threshold, const float nms_threshold, const float sigma, std::vector< int > *indices)
Definition: region_output.h:45
void recover_bbox(int roi_w, int roi_h, int offset_y, std::vector< base::ObjectPtr > *objects)
void fill_ratios(bool with_ratios, base::ObjectPtr obj, const float *bbox)
void fill_bbox3d(bool with_bbox3d, base::ObjectPtr obj, const float *bbox)
void fill_lights(bool with_lights, base::ObjectPtr obj, const float *bbox)
constexpr int numScales
Definition: region_output.h:124
A wrapper around SyncedMemory holders serving as the basic computational unit for images...
Definition: blob.h:88
__host__ __device__ float jaccard_overlap_gpu(const float *bbox1, const float *bbox2)
float ymax
Definition: region_output.h:49
void get_max_score_index(const std::vector< float > &scores, const float threshold, const int top_k, std::vector< std::pair< float, int >> *score_index_vec)
float get_bbox_size(const NormalizedBBox &bbox)
constexpr float maxExpPower
Definition: region_output.h:122
float ymin
Definition: region_output.h:47
void fill_base(base::ObjectPtr obj, const float *bbox)
void apply_nms_fast(const std::vector< NormalizedBBox > &bboxes, const std::vector< float > &scores, const float score_threshold, const float nms_threshold, const float eta, const int top_k, std::vector< int > *indices)
void fill_area_id(bool with_flag, base::ObjectPtr obj, const float *data)
Definition: region_output.h:60
bool sort_score_pair_descend(const std::pair< float, T > &pair1, const std::pair< float, T > &pair2)
Definition: region_output.h:133
float score
Definition: region_output.h:51
Definition: region_output.h:78
__host__ __device__ float bbox_size_gpu(const float *bbox, const bool normalized)
void apply_nms_gpu(const float *bbox_data, const float *conf_data, const std::vector< int > &origin_indices, const int bbox_step, const float confidence_threshold, const int top_k, const float nms_threshold, std::vector< int > *indices, base::Blob< bool > *overlapped, base::Blob< int > *idx_sm, const cudaStream_t &_stream)
Image< uchar > * threshold(Image< T > *src, int t)
Definition: imutil.h:63
int label
Definition: region_output.h:50
int get_objects_gpu(const YoloBlobs &yolo_blobs, const cudaStream_t &stream, const std::vector< base::ObjectSubType > &types, const NMSParam &nms, const yolo::ModelParam &model_param, float light_vis_conf_threshold, float light_swt_conf_threshold, base::Blob< bool > *overlapped, base::Blob< int > *idx_sm, const std::map< base::ObjectSubType, std::vector< int >> &indices, const std::map< base::ObjectSubType, std::vector< float >> &conf_scores)
float xmax
Definition: region_output.h:48
__host__ __device__ float sigmoid_gpu(float x)
bool mask
Definition: region_output.h:53
float xmin
Definition: region_output.h:46
float size
Definition: region_output.h:52
std::shared_ptr< Object > ObjectPtr
Definition: object.h:123
void get_intersect_bbox(const NormalizedBBox &bbox1, const NormalizedBBox &bbox2, NormalizedBBox *intersect_bbox)
const float * get_gpu_data(bool flag, const base::Blob< float > &blob)