base-detection.cpp
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2019 Intel Corporation. All Rights Reserved.
3 
5 #include <easylogging++.h>
6 
7 
8 using namespace InferenceEngine;
9 
10 
11 namespace openvino_helpers
12 {
13  base_detection::base_detection(
14  std::string topoName,
15  const std::string &pathToModel,
16  int maxBatch, bool isBatchDynamic, bool isAsync,
17  bool doRawOutputMessages
18  )
19  : topoName( topoName ), pathToModel( pathToModel )
20  , maxBatch( maxBatch ), isBatchDynamic( isBatchDynamic ), isAsync( isAsync )
21  , enablingChecked( false ), _enabled( false ), doRawOutputMessages( doRawOutputMessages )
22  {
23  }
24 
25 
27  {
28  if( !enabled() || !_request )
29  return;
30  if( isAsync )
31  _request->StartAsync();
32  else
33  _request->Infer();
34  }
35 
36 
38  {
39  if( !enabled() || !_request || !isAsync )
40  return;
41  _request->Wait( IInferRequest::WaitMode::RESULT_READY );
42  }
43 
44 
46  {
47  if( !enablingChecked )
48  {
49  _enabled = !pathToModel.empty();
50  if( !_enabled )
51  LOG(INFO) << topoName + " DISABLED";
52  enablingChecked = true;
53  }
54  return _enabled;
55  }
56 
57 
58  void base_detection::load_into( InferenceEngine::Core & ie, const std::string & deviceName )
59  {
60  if( !enabled() )
61  return;
62 
63  std::map<std::string, std::string> config = { };
64  if( isBatchDynamic )
65  {
66  bool isPossibleDynBatch =
67  deviceName.find( "CPU" ) != std::string::npos ||
68  deviceName.find( "GPU" ) != std::string::npos;
69  if( isPossibleDynBatch )
70  config[PluginConfigParams::KEY_DYN_BATCH_ENABLED] = PluginConfigParams::YES;
71  }
72 
73  //LOG(INFO) << "Loading " << topoName << " model to the " << deviceName << " device";
74  net = ie.LoadNetwork( read_network(), deviceName, config );
75  }
76 }
InferenceEngine::InferRequest::Ptr _request
InferenceEngine::ExecutableNetwork net
LOG(INFO)<< "Log message to default logger"
void load_into(InferenceEngine::Core &ie, const std::string &deviceName)
#define INFO(msg)
Definition: catch.hpp:17429
virtual InferenceEngine::CNNNetwork read_network()=0


librealsense2
Author(s): LibRealSense ROS Team
autogenerated on Thu Dec 22 2022 03:41:42