Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / samples / validation_app / ObjectDetectionProcessor.cpp
index 6109a96..8e3a23e 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2018 Intel Corporation
+// Copyright (C) 2018-2019 Intel Corporation
 // SPDX-License-Identifier: Apache-2.0
 //
 
@@ -24,7 +24,7 @@ ObjectDetectionProcessor::ObjectDetectionProcessor(const std::string& flags_m, c
         double threshold, InferenceEngine::InferencePlugin plugin, CsvDumper& dumper,
         const std::string& flags_a, const std::string& classes_list_file, PreprocessingOptions preprocessingOptions, bool scaleProposalToInputSize)
             : Processor(flags_m, flags_d, flags_i, flags_b, plugin, dumper, "Object detection network", preprocessingOptions),
-              threshold(threshold), annotationsPath(flags_a), subdir(subdir), scaleProposalToInputSize(scaleProposalToInputSize) {
+              annotationsPath(flags_a), subdir(subdir), threshold(threshold), scaleProposalToInputSize(scaleProposalToInputSize) {
     std::ifstream clf(classes_list_file);
     if (!clf) {
         throw UserException(1) <<  "Classes list file \"" << classes_list_file << "\" not found or inaccessible";
@@ -65,19 +65,15 @@ shared_ptr<Processor::InferenceMetrics> ObjectDetectionProcessor::Process(bool s
     for (auto& ann : annCollector.annotations()) {
         std::list<DetectedObject> dobList;
         for (auto& obj : ann.objects) {
-            DetectedObject dob(classes[obj.name], obj.bndbox.xmin, obj.bndbox.ymin, obj.bndbox.xmax, obj.bndbox.ymax, 1.0, obj.difficult != 0);
+            DetectedObject dob(classes[obj.name], static_cast<float>(obj.bndbox.xmin),
+                static_cast<float>(obj.bndbox.ymin), static_cast<float>(obj.bndbox.xmax),
+                static_cast<float>(obj.bndbox.ymax), 1.0f, obj.difficult != 0);
             dobList.push_back(dob);
         }
         ImageDescription id(dobList);
         desiredForFiles.insert(std::pair<std::string, ImageDescription>(ann.folder + "/" + (!subdir.empty() ? subdir + "/" : "") + ann.filename, id));
     }
 
-
-    ImageDecoder decoder;
-
-    const int maxProposalCount = outputDims[1];
-    const int objectSize = outputDims[0];
-
     for (auto & item : outInfo) {
         DataPtr outputData = item.second;
         if (!outputData) {
@@ -104,18 +100,17 @@ shared_ptr<Processor::InferenceMetrics> ObjectDetectionProcessor::Process(bool s
 
     while (iter != annCollector.annotations().end()) {
         std::vector<std::string> files;
-        int b = 0;
+        size_t b = 0;
 
         int filesWatched = 0;
         for (; b < batch && iter != annCollector.annotations().end(); b++, iter++, filesWatched++) {
             expected[b] = *iter;
             string filename = iter->folder + "/" + (!subdir.empty() ? subdir + "/" : "") + iter->filename;
             try {
-                Size orig_size = decoder.insertIntoBlob(std::string(imagesPath) + "/" + filename, b, *firstInputBlob, preprocessingOptions);
                 float scale_x, scale_y;
 
-                scale_x = 1.0 / iter->size.width;  // orig_size.width;
-                scale_y = 1.0 / iter->size.height;  // orig_size.height;
+                scale_x = 1.0f / iter->size.width;  // orig_size.width;
+                scale_y = 1.0f / iter->size.height;  // orig_size.height;
 
                 if (scaleProposalToInputSize) {
                     scale_x *= firstInputBlob->dims()[0];
@@ -128,6 +123,7 @@ shared_ptr<Processor::InferenceMetrics> ObjectDetectionProcessor::Process(bool s
                 files.push_back(filename);
             } catch (const InferenceEngineException& iex) {
                 slog::warn << "Can't read file " << this->imagesPath + "/" + filename << slog::endl;
+                slog::warn << "Error: " << iex.what() << slog::endl;
                 // Could be some non-image file in directory
                 b--;
                 continue;
@@ -135,9 +131,6 @@ shared_ptr<Processor::InferenceMetrics> ObjectDetectionProcessor::Process(bool s
         }
 
         if (files.size() == batch) {
-            InferenceEngine::StatusCode sts;
-            InferenceEngine::ResponseDesc dsc;
-
             // Infer model
             Infer(progress, filesWatched, im);
 
@@ -146,7 +139,7 @@ shared_ptr<Processor::InferenceMetrics> ObjectDetectionProcessor::Process(bool s
 
             // Calculating similarity
             //
-            for (int b = 0; b < files.size(); b++) {
+            for (size_t b = 0; b < files.size(); b++) {
                 ImageDescription result(detectedObjects[files[b]]);
                 im.apc.consumeImage(result, scaledDesiredForFiles.at(files[b]));
             }