Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / samples / hello_classification / main.cpp
index d9482e1..b3b5158 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2018 Intel Corporation
+// Copyright (C) 2018-2019 Intel Corporation
 // SPDX-License-Identifier: Apache-2.0
 //
 
@@ -14,6 +14,7 @@
 
 #include <opencv2/opencv.hpp>
 #include <inference_engine.hpp>
+#include <samples/classification_results.h>
 
 using namespace InferenceEngine;
 
@@ -41,8 +42,7 @@ int wmain(int argc, wchar_t *argv[]) {
         // -----------------------------------------------------------------------------------------------------
 
         // --------------------------- 1. Load Plugin for inference engine -------------------------------------
-        PluginDispatcher dispatcher({_T("../../../lib/intel64"), _T("")});
-        InferencePlugin plugin(dispatcher.getSuitablePlugin(TargetDevice::eCPU));
+        InferencePlugin plugin(PluginDispatcher().getSuitablePlugin(TargetDevice::eCPU));
         // -----------------------------------------------------------------------------------------------------
 
         // --------------------------- 2. Read IR Generated by ModelOptimizer (.xml and .bin files) ------------
@@ -103,18 +103,10 @@ int wmain(int argc, wchar_t *argv[]) {
 
         // --------------------------- 8. Process output ------------------------------------------------------
         Blob::Ptr output = infer_request.GetBlob(output_name);
-        auto output_data = output->buffer().as<PrecisionTrait<Precision::FP32>::value_type*>();
+        // Print classification results
+        ClassificationResult classificationResult(output, {fileNameToString(input_image_path)});
+        classificationResult.print();
 
-        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;
-        }
         // -----------------------------------------------------------------------------------------------------
     } catch (const std::exception & ex) {
         std::cerr << ex.what() << std::endl;