Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / samples / hello_autoresize_classification / main.cpp
index 2ac9337..9700416 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2018 Intel Corporation
+// Copyright (C) 2018-2019 Intel Corporation
 // SPDX-License-Identifier: Apache-2.0
 //
 
@@ -10,6 +10,7 @@
 
 #include <inference_engine.hpp>
 #include <samples/ocv_common.hpp>
+#include <samples/classification_results.h>
 
 using namespace InferenceEngine;
 
@@ -28,11 +29,11 @@ int main(int argc, char *argv[]) {
         // -----------------------------------------------------------------------------------------------------
 
         // --------------------------- 1. Load Plugin for inference engine -------------------------------------
-        InferencePlugin plugin = PluginDispatcher({"../../../lib/intel64", ""}).getPluginByDevice(device_name);
+        InferencePlugin plugin = PluginDispatcher().getPluginByDevice(device_name);
         // -----------------------------------------------------------------------------------------------------
 
         // --------------------------- 2. Read IR Generated by ModelOptimizer (.xml and .bin files) ------------
-        int batchSize = 1;
+        size_t batchSize = 1;
         CNNNetReader network_reader;
         network_reader.ReadNetwork(input_model);
         network_reader.ReadWeights(input_model.substr(0, input_model.size() - 4) + ".bin");
@@ -90,18 +91,9 @@ int main(int argc, char *argv[]) {
 
         // --------------------------- 8. Process output ------------------------------------------------------
         Blob::Ptr output = infer_request.GetBlob(output_name);
-        auto output_data = output->buffer().as<PrecisionTrait<Precision::FP32>::value_type*>();
-
-        std::vector<unsigned> results;
-        /*  This is to sort output probabilities and put it to results vector */
-        TopResults(10, *output, results);
-
-        std::cout << std::endl << "Top 10 results:" << std::endl << std::endl;
-        for (size_t id = 0; id < 10; ++id) {
-            std::cout.precision(7);
-            auto result = output_data[results[id]];
-            std::cout << std::left << std::fixed << result << " label #" << results[id] << std::endl;
-        }
+        // Print classification results
+        ClassificationResult classificationResult(output, {input_image_path});
+        classificationResult.print();
         // -----------------------------------------------------------------------------------------------------
 
         std::cout << std::endl << "total inference time: " << total << std::endl;