1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
16 #include "ObjectDetectionProcessor.hpp"
20 class SSDObjectDetectionProcessor : public ObjectDetectionProcessor {
22 std::map<std::string, std::list<DetectedObject>> processResult(std::vector<std::string> files) {
23 std::map<std::string, std::list<DetectedObject>> detectedObjects;
25 std::string firstOutputName = this->outInfo.begin()->first;
26 const auto detectionOutArray = inferRequest.GetBlob(firstOutputName);
27 const float *box = detectionOutArray->buffer().as<float*>();
29 const size_t maxProposalCount = outputDims[1];
30 const size_t objectSize = outputDims[0];
32 for (size_t b = 0; b < batch; b++) {
34 std::list<DetectedObject> dr = std::list<DetectedObject>();
35 detectedObjects.insert(std::pair<std::string, std::list<DetectedObject>>(fn, dr));
38 for (size_t i = 0; i < maxProposalCount; i++) {
39 float image_id = box[i * objectSize + 0];
40 float label = box[i * objectSize + 1];
41 float confidence = box[i * objectSize + 2];
42 float xmin = box[i * objectSize + 3] * inputDims[0];
43 float ymin = box[i * objectSize + 4] * inputDims[1];
44 float xmax = box[i * objectSize + 5] * inputDims[0];
45 float ymax = box[i * objectSize + 6] * inputDims[1];
47 if (image_id < 0 /* better than check == -1 */) {
51 detectedObjects[files[static_cast<size_t>(image_id)]].push_back(
52 DetectedObject(static_cast<int>(label), xmin, ymin, xmax, ymax, confidence));
55 return detectedObjects;
59 SSDObjectDetectionProcessor(const std::string& flags_m, const std::string& flags_d, const std::string& flags_i, const std::string& subdir, int flags_b,
61 InferencePlugin plugin, CsvDumper& dumper,
62 const std::string& flags_a, const std::string& classes_list_file) :
64 ObjectDetectionProcessor(flags_m, flags_d, flags_i, subdir, flags_b, threshold,
65 plugin, dumper, flags_a, classes_list_file, PreprocessingOptions(false, ResizeCropPolicy::Resize), true) { }