JeVois  1.20
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
NetworkHailo.H
Go to the documentation of this file.
1 // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 //
3 // JeVois Smart Embedded Machine Vision Toolkit - Copyright (C) 2022 by Laurent Itti, the University of Southern
4 // California (USC), and iLab at USC. See http://iLab.usc.edu and http://jevois.org for information about this project.
5 //
6 // This file is part of the JeVois Smart Embedded Machine Vision Toolkit. This program is free software; you can
7 // redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software
8 // Foundation, version 2. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
10 // License for more details. You should have received a copy of the GNU General Public License along with this program;
11 // if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
12 //
13 // Contact information: Laurent Itti - 3641 Watt Way, HNB-07A - Los Angeles, CA 90089-2520 - USA.
14 // Tel: +1 213 740 3527 - itti@pollux.usc.edu - http://iLab.usc.edu - http://jevois.org
15 // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
16 /*! \file */
17 
18 #pragma once
19 
20 #ifdef JEVOIS_PRO
21 
22 #include <jevois/DNN/Network.H>
23 
24 namespace hailort
25 { class Device; class ConfiguredNetworkGroup; class InputVStream; class OutputVStream; class ActivatedNetworkGroup; }
26 
27 namespace jevois
28 {
29  namespace dnn
30  {
31  //! Wrapper around an DNN neural network running on the Hailo8 neural accelerator
32  /*! Note that this network type does not support setting intensors or outtensors externally, these are fixed in the
33  HEF file. \ingroup dnn */
35  public jevois::Parameter<network::dataroot, network::model, network::dequant, network::turbo>
36  {
37  public:
38  //! Constructor
39  NetworkHailo(std::string const & instance);
40 
41  //! Destructor
42  virtual ~NetworkHailo();
43 
44  //! Freeze/unfreeze parameters that users should not change while running
45  void freeze(bool doit) override;
46 
47  //! Get shapes of all input tensors
48  virtual std::vector<vsi_nn_tensor_attr_t> inputShapes() override;
49 
50  //! Get shapes of all output tensors
51  virtual std::vector<vsi_nn_tensor_attr_t> outputShapes() override;
52 
53  protected:
54  //! Load from disk
55  void load() override;
56 
57  //! Process input blobs and obtain output blobs
58  std::vector<cv::Mat> doprocess(std::vector<cv::Mat> const & blobs,
59  std::vector<std::string> & info) override;
60 
61  void onParamChange(network::turbo const & par, bool const & newval) override;
62 
63  private:
64  std::unique_ptr<hailort::Device> itsDevice;
65  std::shared_ptr<hailort::ConfiguredNetworkGroup> itsNetGroup;
66  std::vector<hailort::InputVStream> itsInStreams;
67  std::vector<hailort::OutputVStream> itsOutStreams;
68  std::unique_ptr<hailort::ActivatedNetworkGroup> itsActiveNetGroup;
69  std::vector<vsi_nn_tensor_attr_t> itsInAttrs, itsOutAttrs;
70  std::vector<cv::Mat> itsRawOutMats, itsOutMats;
71  };
72 
73  } // namespace dnn
74 } // namespace jevois
75 
76 #endif // JEVOIS_PRO
Network.H
jevois::dnn::NetworkHailo::outputShapes
virtual std::vector< vsi_nn_tensor_attr_t > outputShapes() override
Get shapes of all output tensors.
Definition: NetworkHailo.C:60
jevois::dnn::NetworkHailo::doprocess
std::vector< cv::Mat > doprocess(std::vector< cv::Mat > const &blobs, std::vector< std::string > &info) override
Process input blobs and obtain output blobs.
Definition: NetworkHailo.C:168
jevois::dnn::NetworkHailo
Wrapper around an DNN neural network running on the Hailo8 neural accelerator.
Definition: NetworkHailo.H:34
hailort
Definition: NetworkHailo.H:24
jevois::dnn::NetworkHailo::freeze
void freeze(bool doit) override
Freeze/unfreeze parameters that users should not change while running.
Definition: NetworkHailo.C:72
jevois::dnn::NetworkHailo::inputShapes
virtual std::vector< vsi_nn_tensor_attr_t > inputShapes() override
Get shapes of all input tensors.
Definition: NetworkHailo.C:56
jevois
Definition: Concepts.dox:1
jevois::dnn::NetworkHailo::NetworkHailo
NetworkHailo(std::string const &instance)
Constructor.
Definition: NetworkHailo.C:35
jevois::dnn::NetworkHailo::onParamChange
void onParamChange(network::turbo const &par, bool const &newval) override
Definition: NetworkHailo.C:162
jevois::dnn::NetworkHailo::~NetworkHailo
virtual ~NetworkHailo()
Destructor.
Definition: NetworkHailo.C:64
jevois::dnn::Network
Abstract class to represent a neural network.
Definition: Network.H:160
jevois::dnn::NetworkHailo::load
void load() override
Load from disk.
Definition: NetworkHailo.C:80