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 
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 }
openvino_helpers::base_detection::read_network
virtual InferenceEngine::CNNNetwork read_network()=0
easyloggingpp.h
openvino_helpers::base_detection::isAsync
const bool isAsync
Definition: base-detection.h:26
openvino_helpers::base_detection::_request
InferenceEngine::InferRequest::Ptr _request
Definition: base-detection.h:21
openvino_helpers::base_detection::load_into
void load_into(InferenceEngine::Core &ie, const std::string &deviceName)
Definition: base-detection.cpp:58
openvino_helpers::base_detection::pathToModel
std::string pathToModel
Definition: base-detection.h:23
string
GLsizei const GLchar *const * string
Definition: glad/glad/glad.h:2861
openvino_helpers::base_detection::isBatchDynamic
bool isBatchDynamic
Definition: base-detection.h:25
openvino_helpers::base_detection::_enabled
bool _enabled
Definition: base-detection.h:28
openvino_helpers::base_detection::wait
virtual void wait()
Definition: base-detection.cpp:37
LOG
LOG(INFO)<< "Log message to default logger"
openvino_helpers::base_detection::net
InferenceEngine::ExecutableNetwork net
Definition: base-detection.h:20
openvino_helpers::base_detection::enablingChecked
bool enablingChecked
Definition: base-detection.h:27
openvino_helpers
Definition: age-gender-detection.cpp:12
INFO
INFO(m)
openvino_helpers::base_detection::enabled
bool enabled() const
Definition: base-detection.cpp:45
test-d405-calibration-stream.config
config
Definition: test-d405-calibration-stream.py:22
base-detection.h
openvino_helpers::base_detection::topoName
std::string topoName
Definition: base-detection.h:22
openvino_helpers::base_detection::submit_request
virtual void submit_request()
Definition: base-detection.cpp:26


librealsense2
Author(s): LibRealSense ROS Team
autogenerated on Mon Apr 22 2024 02:12:55