JeVois  1.20
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
PreProcessorPython.H
Go to the documentation of this file.
1 // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 //
3 // JeVois Smart Embedded Machine Vision Toolkit - Copyright (C) 2021 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 
22 
23 namespace jevois
24 {
25  namespace dnn
26  {
27  class PreProcessorPythonImpl;
28  class PreProcessorForPython;
29 
30  //! Pre-Processor for neural network pipeline written in python
31  /*! This is the first step in a deep neural network processing Pipeline. \ingroup dnn */
32  class PreProcessorPython : public PreProcessor, public jevois::Parameter<preprocessor::pypre>
33  {
34  public:
35  //! Constructor
36  PreProcessorPython(std::string const & instance);
37 
38  //! Destructor
39  virtual ~PreProcessorPython();
40 
41  //! Freeze/unfreeze parameters that users should not change while running
42  void freeze(bool doit) override;
43 
44  //! Extract blobs from input image
45  std::vector<cv::Mat> process(cv::Mat const & img, bool swaprb, std::vector<vsi_nn_tensor_attr_t> const & attrs,
46  std::vector<cv::Rect> & crops) override;
47 
48  //! Report what happened in last process() to console/output video/GUI
49  void report(jevois::StdModule * mod, jevois::RawImage * outimg = nullptr,
50  jevois::OptGUIhelper * helper = nullptr, bool overlay = true, bool idle = false) override;
51 
52  protected:
53  // Load the python code as soon as the file is set, and call init() on it if defined
54  void onParamChange(preprocessor::pypre const & param, std::string const & newval) override;
55 
56  // Python init() may create new dynamic parameters, but in onParamChange() we are locked up, so we need to use a
57  // sub-Component for our actual implementation, and the sub can get its dynamic parameters created while our own
58  // params are locked up...
59  std::shared_ptr<PreProcessorPythonImpl> itsImpl;
60  };
61 
62  } // namespace dnn
63 } // namespace jevois
jevois::dnn::PreProcessorPython::~PreProcessorPython
virtual ~PreProcessorPython()
Destructor.
Definition: PreProcessorPython.C:154
jevois::dnn::PreProcessorPython::itsImpl
std::shared_ptr< PreProcessorPythonImpl > itsImpl
Definition: PreProcessorPython.H:59
jevois::dnn::PreProcessorPython
Pre-Processor for neural network pipeline written in python.
Definition: PreProcessorPython.H:32
jevois::RawImage
A raw image as coming from a V4L2 Camera and/or being sent out to a USB Gadget.
Definition: RawImage.H:110
jevois::dnn::PreProcessorPython::PreProcessorPython
PreProcessorPython(std::string const &instance)
Constructor.
Definition: PreProcessorPython.C:147
jevois::GUIhelper
Helper class to assist modules in creating graphical and GUI elements.
Definition: GUIhelper.H:128
jevois
Definition: Concepts.dox:1
jevois::dnn::PreProcessor
Pre-Processor for neural network pipeline.
Definition: PreProcessor.H:108
jevois::dnn::PreProcessorPython::freeze
void freeze(bool doit) override
Freeze/unfreeze parameters that users should not change while running.
Definition: PreProcessorPython.C:158
PreProcessor.H
jevois::StdModule
Base class for a module that supports standardized serial messages.
Definition: Module.H:232
jevois::dnn::PreProcessorPython::report
void report(jevois::StdModule *mod, jevois::RawImage *outimg=nullptr, jevois::OptGUIhelper *helper=nullptr, bool overlay=true, bool idle=false) override
Report what happened in last process() to console/output video/GUI.
Definition: PreProcessorPython.C:181
PythonWrapper.H
jevois::dnn::PreProcessorPython::onParamChange
void onParamChange(preprocessor::pypre const &param, std::string const &newval) override
Definition: PreProcessorPython.C:168
jevois::dnn::PreProcessorPython::process
std::vector< cv::Mat > process(cv::Mat const &img, bool swaprb, std::vector< vsi_nn_tensor_attr_t > const &attrs, std::vector< cv::Rect > &crops) override
Extract blobs from input image.
Definition: PreProcessorPython.C:175