JeVois  1.22
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
Loading...
Searching...
No Matches
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#include <hailo/hailort.hpp>
24
25namespace hailort
26{ class Device; class ConfiguredNetworkGroup; class InputVStream; class OutputVStream; class ActivatedNetworkGroup; }
27
28namespace jevois
29{
30 namespace dnn
31 {
32 //! Wrapper around an DNN neural network running on the Hailo8 neural accelerator
33 /*! Note that this network type does not support setting intensors or outtensors externally, these are fixed in the
34 HEF file. \ingroup dnn */
36 public jevois::Parameter<network::dataroot, network::model, network::dequant, network::turbo>
37 {
38 public:
39 //! Constructor
40 NetworkHailo(std::string const & instance);
41
42 //! Destructor
43 virtual ~NetworkHailo();
44
45 //! Freeze/unfreeze parameters that users should not change while running
46 void freeze(bool doit) override;
47
48 //! Get shapes of all input tensors
49 virtual std::vector<vsi_nn_tensor_attr_t> inputShapes() override;
50
51 //! Hailo-only get input stream infos
52 std::vector<hailo_vstream_info_t> inputInfos() const;
53
54 //! Get shapes of all output tensors
55 virtual std::vector<vsi_nn_tensor_attr_t> outputShapes() override;
56
57 //! Hailo-only get input stream infos, can be used to post-process quantized outputs
58 std::vector<hailo_vstream_info_t> outputInfos() const;
59
60 protected:
61 //! Load from disk
62 void load() override;
63
64 //! Process input blobs and obtain output blobs
65 std::vector<cv::Mat> doprocess(std::vector<cv::Mat> const & blobs,
66 std::vector<std::string> & info) override;
67
68 void onParamChange(network::turbo const & par, bool const & newval) override;
69
70 private:
71 std::unique_ptr<hailort::Device> itsDevice;
72 std::shared_ptr<hailort::ConfiguredNetworkGroup> itsNetGroup;
73 std::vector<hailort::InputVStream> itsInStreams;
74 std::vector<hailort::OutputVStream> itsOutStreams;
75 std::unique_ptr<hailort::ActivatedNetworkGroup> itsActiveNetGroup;
76 std::vector<vsi_nn_tensor_attr_t> itsInAttrs, itsOutAttrs;
77 std::vector<cv::Mat> itsRawOutMats, itsOutMats;
78 };
79
80 } // namespace dnn
81} // namespace jevois
82
83#endif // JEVOIS_PRO
Wrapper around an DNN neural network running on the Hailo8 neural accelerator.
std::vector< cv::Mat > doprocess(std::vector< cv::Mat > const &blobs, std::vector< std::string > &info) override
Process input blobs and obtain output blobs.
void load() override
Load from disk.
std::vector< hailo_vstream_info_t > inputInfos() const
Hailo-only get input stream infos.
virtual ~NetworkHailo()
Destructor.
void onParamChange(network::turbo const &par, bool const &newval) override
void freeze(bool doit) override
Freeze/unfreeze parameters that users should not change while running.
virtual std::vector< vsi_nn_tensor_attr_t > inputShapes() override
Get shapes of all input tensors.
virtual std::vector< vsi_nn_tensor_attr_t > outputShapes() override
Get shapes of all output tensors.
std::vector< hailo_vstream_info_t > outputInfos() const
Hailo-only get input stream infos, can be used to post-process quantized outputs.
Abstract class to represent a neural network.
Definition Network.H:212
Main namespace for all JeVois classes and functions.
Definition Concepts.dox:2