@@ -211,92 +211,11 @@ class DetectionOutputLayerImpl : public DetectionOutputLayer
211
211
return false ;
212
212
}
213
213
214
- #ifdef HAVE_OPENCL
215
- bool forward_ocl (InputArrayOfArrays inputs_arr, OutputArrayOfArrays outputs_arr, OutputArrayOfArrays internals_arr)
216
- {
217
- std::vector<Mat> inpvec;
218
- std::vector<Mat> outputs;
219
-
220
- inputs_arr.getMatVector (inpvec);
221
- outputs_arr.getMatVector (outputs);
222
-
223
- std::vector<Mat*> inputs (inpvec.size ());
224
- for (size_t i = 0 ; i < inpvec.size (); i++)
225
- inputs[i] = &inpvec[i];
226
-
227
- std::vector<LabelBBox> allDecodedBBoxes;
228
- std::vector<std::vector<std::vector<float > > > allConfidenceScores;
229
-
230
- int num = inputs[0 ]->size [0 ];
231
-
232
- // extract predictions from input layers
233
- {
234
- int numPriors = inputs[2 ]->size [2 ] / 4 ;
235
-
236
- const float * locationData = inputs[0 ]->ptr <float >();
237
- const float * confidenceData = inputs[1 ]->ptr <float >();
238
- const float * priorData = inputs[2 ]->ptr <float >();
239
-
240
- // Retrieve all location predictions
241
- std::vector<LabelBBox> allLocationPredictions;
242
- GetLocPredictions (locationData, num, numPriors, _numLocClasses,
243
- _shareLocation, _locPredTransposed, allLocationPredictions);
244
-
245
- // Retrieve all confidences
246
- GetConfidenceScores (confidenceData, num, numPriors, _numClasses, allConfidenceScores);
247
-
248
- // Retrieve all prior bboxes
249
- std::vector<util::NormalizedBBox> priorBBoxes;
250
- std::vector<std::vector<float > > priorVariances;
251
- GetPriorBBoxes (priorData, numPriors, priorBBoxes, priorVariances);
252
-
253
- // Decode all loc predictions to bboxes
254
- DecodeBBoxesAll (allLocationPredictions, priorBBoxes, priorVariances, num,
255
- _shareLocation, _numLocClasses, _backgroundLabelId,
256
- _codeType, _varianceEncodedInTarget, false , allDecodedBBoxes);
257
- }
258
-
259
- size_t numKept = 0 ;
260
- std::vector<std::map<int , std::vector<int > > > allIndices;
261
- for (int i = 0 ; i < num; ++i)
262
- {
263
- numKept += processDetections_ (allDecodedBBoxes[i], allConfidenceScores[i], allIndices);
264
- }
265
-
266
- if (numKept == 0 )
267
- {
268
- // Set confidences to zeros.
269
- Range ranges[] = {Range::all (), Range::all (), Range::all (), Range (2 , 3 )};
270
- outputs[0 ](ranges).setTo (0 );
271
- return true ;
272
- }
273
- int outputShape[] = {1 , 1 , (int )numKept, 7 };
274
- Mat mat (4 , outputShape, CV_32F);
275
- float * outputsData = mat.ptr <float >();
276
-
277
- size_t count = 0 ;
278
- for (int i = 0 ; i < num; ++i)
279
- {
280
- count += outputDetections_ (i, &outputsData[count * 7 ],
281
- allDecodedBBoxes[i], allConfidenceScores[i],
282
- allIndices[i]);
283
- }
284
- UMat& output = outputs_arr.getUMatRef (0 );
285
- output = mat.getUMat (ACCESS_READ);
286
- CV_Assert (count == numKept);
287
- return true ;
288
- }
289
- #endif
290
-
291
214
void forward (InputArrayOfArrays inputs_arr, OutputArrayOfArrays outputs_arr, OutputArrayOfArrays internals_arr)
292
215
{
293
216
CV_TRACE_FUNCTION ();
294
217
CV_TRACE_ARG_VALUE (name, " name" , name.c_str ());
295
218
296
- CV_OCL_RUN ((preferableTarget == DNN_TARGET_OPENCL) &&
297
- OCL_PERFORMANCE_CHECK (ocl::Device::getDefault ().isIntel ()),
298
- forward_ocl (inputs_arr, outputs_arr, internals_arr))
299
-
300
219
Layer::forward_fallback (inputs_arr, outputs_arr, internals_arr);
301
220
}
302
221
0 commit comments