Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / samples / validation_app / ObjectDetectionProcessor.hpp
1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4
5 #pragma once
6
7 #include <iostream>
8 #include <limits>
9 #include <map>
10 #include <memory>
11 #include <string>
12 #include <list>
13 #include <vector>
14
15 #include "Processor.hpp"
16
17 #include "VOCAnnotationParser.hpp"
18
19 using namespace std;
20
21 class ObjectDetectionProcessor : public Processor {
22 public:
23     struct ObjectDetectionInferenceMetrics : public InferenceMetrics {
24     public:
25         AveragePrecisionCalculator apc;
26
27         explicit ObjectDetectionInferenceMetrics(double threshold) : apc(threshold) { }
28     };
29
30 protected:
31     std::string annotationsPath;
32     std::string subdir;
33     std::map<std::string, int> classes;
34     double threshold;
35
36     bool scaleProposalToInputSize;
37
38     virtual std::map<std::string, std::list<DetectedObject>> processResult(std::vector<std::string> files) = 0;
39
40 public:
41     ObjectDetectionProcessor(const std::string& flags_m, const std::string& flags_d, const std::string& flags_i, const std::string& subdir, int flags_b,
42             double threshold,
43             InferenceEngine::InferencePlugin plugin, CsvDumper& dumper,
44             const std::string& flags_a, const std::string& classes_list_file, PreprocessingOptions preprocessingOptions, bool scaleSizeToInputSize);
45
46     shared_ptr<InferenceMetrics> Process(bool stream_output);
47     virtual void Report(const InferenceMetrics& im);
48     virtual ~ObjectDetectionProcessor() {}
49 };