Publishing R3
[platform/upstream/dldt.git] / inference-engine / samples / validation_app / ObjectDetectionProcessor.hpp
1 /*
2 // Copyright (c) 2018 Intel Corporation
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //      http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 */
16
17 #pragma once
18
19 #include <iostream>
20 #include <limits>
21 #include <map>
22 #include <memory>
23 #include <string>
24 #include <list>
25 #include <vector>
26
27 #include "Processor.hpp"
28
29 #include "VOCAnnotationParser.hpp"
30
31 using namespace std;
32
33 class ObjectDetectionProcessor : public Processor {
34 public:
35     struct ObjectDetectionInferenceMetrics : public InferenceMetrics {
36     public:
37         AveragePrecisionCalculator apc;
38
39         explicit ObjectDetectionInferenceMetrics(double threshold) : apc(threshold) { }
40     };
41
42 protected:
43     std::string annotationsPath;
44     std::string subdir;
45     std::map<std::string, int> classes;
46     double threshold;
47
48     bool scaleProposalToInputSize;
49
50     virtual std::map<std::string, std::list<DetectedObject>> processResult(std::vector<std::string> files) = 0;
51
52 public:
53     ObjectDetectionProcessor(const std::string& flags_m, const std::string& flags_d, const std::string& flags_i, const std::string& subdir, int flags_b,
54             double threshold,
55             InferenceEngine::InferencePlugin plugin, CsvDumper& dumper,
56             const std::string& flags_a, const std::string& classes_list_file, PreprocessingOptions preprocessingOptions, bool scaleSizeToInputSize);
57
58     shared_ptr<InferenceMetrics> Process();
59     virtual void Report(const InferenceMetrics& im);
60     virtual ~ObjectDetectionProcessor() {}
61 };