MCPcopy Create free account
hub / github.com/OAID/Tengine / generate_bounding_box

Function generate_bounding_box

examples/caffe_wrapper/mtcnn/caffe_mtcnn_utils.cpp:157–212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155}
156
157void generate_bounding_box(const float* confidence_data, int confidence_size, const float* reg_data, float scale,
158 float threshold, int feature_h, int feature_w, std::vector<face_box>& output,
159 bool transposed)
160{
161 int stride = 2;
162 int cellSize = 12;
163
164 int img_h = feature_h;
165 int img_w = feature_w;
166
167 int count = confidence_size / 2;
168 confidence_data += count;
169
170 for(int i = 0; i < count; i++)
171 {
172 if(*(confidence_data + i) >= threshold)
173 {
174 int y = i / img_w;
175 int x = i - img_w * y;
176
177 float top_x = ( int )((x * stride + 1) / scale);
178 float top_y = ( int )((y * stride + 1) / scale);
179 float bottom_x = ( int )((x * stride + cellSize) / scale);
180 float bottom_y = ( int )((y * stride + cellSize) / scale);
181
182 face_box box;
183
184 box.x0 = top_x;
185 box.y0 = top_y;
186 box.x1 = bottom_x;
187 box.y1 = bottom_y;
188
189 box.score = *(confidence_data + i);
190
191 int c_offset = y * img_w + x;
192 int c_size = img_w * img_h;
193
194 if(transposed)
195 {
196 box.regress[1] = reg_data[c_offset];
197 box.regress[0] = reg_data[c_offset + c_size];
198 box.regress[3] = reg_data[c_offset + 2 * c_size];
199 box.regress[2] = reg_data[c_offset + 3 * c_size];
200 }
201 else
202 {
203 box.regress[0] = reg_data[c_offset];
204 box.regress[1] = reg_data[c_offset + c_size];
205 box.regress[2] = reg_data[c_offset + 2 * c_size];
206 box.regress[3] = reg_data[c_offset + 3 * c_size];
207 }
208
209 output.push_back(box);
210 }
211 }
212}
213
214void set_input_buffer(std::vector<cv::Mat>& input_channels, float* input_data, const int height, const int width)

Callers 1

run_PNetMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected