JeVois  1.7
JeVois Smart Embedded Machine Vision Toolkit
Share this page:

#include <jevois/Core/PythonModule.H>

Wrapper module to allow users to develop new modules written in Python.

This wrapper module calls a process function written in Python on every frame. Note how sendSerial() is added dynamically after the python class is defined, as a new member function of the class.

Definition at line 143 of file PythonModule.H.

Inheritance diagram for jevois::PythonModule:
Collaboration diagram for jevois::PythonModule:

Public Member Functions

 PythonModule (VideoMapping const &m)
 Constructor needs the full path to a Python source code file. More...
 
virtual ~PythonModule ()
 Virtual destructor for safe inheritance. More...
 
virtual void process (InputFrame &&inframe, OutputFrame &&outframe) override
 Processing function, version that receives a frame from camera and sends a frame out over USB. More...
 
virtual void process (InputFrame &&inframe) override
 Processing function, version that receives a frame from camera and does not use USB. More...
 
virtual void parseSerial (std::string const &str, std::shared_ptr< UserInterface > s) override
 Receive a string from a serial port which contains a user command. More...
 
virtual void supportedCommands (std::ostream &os) override
 Human-readable description of this Module's supported custom commands. More...
 
void postUninit () override
 Optionally call uninit() python module function, if implemented. More...
 
- Public Member Functions inherited from jevois::Module
 Module (std::string const &instance)
 Constructor. More...
 
virtual ~Module ()
 Virtual destructor for safe inheritance. More...
 
virtual void sendSerial (std::string const &str)
 Send a string over the 'serout' serial port. More...
 
- Public Member Functions inherited from jevois::Component
 Component (std::string const &instance)
 Constructor. More...
 
virtual ~Component ()
 Virtual destructor for safe inheritance. More...
 
template<>
std::shared_ptr< ComponentgetSubComponent (std::string const &instance) const
 
template<class Comp , typename... Args>
std::shared_ptr< Comp > addSubComponent (std::string const &instance, Args &&...args)
 Pseudo-constructor: construct and add another component as a subcomponent of this one. More...
 
template<class Comp >
void removeSubComponent (std::shared_ptr< Comp > &component)
 Remove a sub-Component from this Component, by shared_ptr. More...
 
void removeSubComponent (std::string const &instance, bool warnIfNotFound=true)
 Remove a sub-Component from this Component, by instance name. More...
 
template<class Comp = jevois::Component>
std::shared_ptr< Comp > getSubComponent (std::string const &instance) const
 Get a sub-component by instance name. More...
 
bool isTopLevel () const
 Returns true if this component is top-level, i.e., its parent is jevois::Manager. More...
 
bool initialized () const
 Has this component been initialized yet? More...
 
std::string const & className () const
 The class name of this component. More...
 
std::string const & instanceName () const
 The instance name of this component. More...
 
template<typename T >
std::vector< std::string > setParamVal (std::string const &paramdescriptor, T const &val)
 Set a parameter value. More...
 
template<typename T >
void setParamValUnique (std::string const &paramdescriptor, T const &val)
 Set a parameter value, simple version assuming only one parameter match. More...
 
template<typename T >
std::vector< std::pair< std::string, T > > getParamVal (std::string const &paramdescriptor) const
 Get parameter(s) value(s) by descriptor. More...
 
template<typename T >
getParamValUnique (std::string const &paramdescriptor) const
 Get a parameter value, simple version assuming only one parameter match. More...
 
std::vector< std::string > setParamString (std::string const &paramdescriptor, std::string const &val)
 Set a parameter value, by string. More...
 
void setParamStringUnique (std::string const &paramdescriptor, std::string const &val)
 Set a parameter value by string, simple version assuming only one parameter match. More...
 
std::vector< std::pair< std::string, std::string > > getParamString (std::string const &paramdescriptor) const
 Get a parameter value, by string. More...
 
std::string getParamStringUnique (std::string const &paramdescriptor) const
 Get a parameter value by string, simple version assuming only one parameter match. More...
 
void freezeParam (std::string const &paramdescriptor)
 Freeze a parameter, by name, see ParameterBase::freeze() More...
 
void unFreezeParam (std::string const &paramdescriptor)
 Unfreeze a parameter, by name, see ParameterBase::unFreeze() More...
 
void freezeAllParams ()
 Freeze all parameters. More...
 
void unFreezeAllParams ()
 Unfreeze all parameters. More...
 
std::string descriptor () const
 Get our full descriptor (including all parents) as [Instancename]:[...]:[...]. More...
 
void setParamsFromFile (std::string const &filename)
 Set some parameters from a file. More...
 
std::istream & setParamsFromStream (std::istream &is, std::string const &absfile)
 Set some parameters from an open stream. More...
 
void setPath (std::string const &path)
 Assign a filesystem path to this component. More...
 
std::string absolutePath (std::string const &path="")
 If given path is relative (not starting with /), prepend the Component path to it. More...
 
- Public Member Functions inherited from jevois::ParameterRegistry
virtual ~ParameterRegistry ()
 Virtual destructor for safe inheritance. More...
 

Related Functions

(Note that these are not member functions.)

void pythonModuleSetEngine (jevois::Engine *e)
 Initialize Python, numpy, and allow python modules to send serial outputs through the JeVois Engine. More...
 

Additional Inherited Members

- Protected Member Functions inherited from jevois::Component
virtual void preInit ()
 Called before all sub-Components are init()ed. More...
 
virtual void postInit ()
 Called after all sub-Components are init()ed. More...
 
virtual void preUninit ()
 Called before all sub-Components are uninit()ed. More...
 
- Protected Member Functions inherited from jevois::ParameterRegistry
void addParameter (ParameterBase *const param)
 The Parameter class uses this method to register itself on construction with its owning Component. More...
 
void removeParameter (ParameterBase *const param)
 The Parameter class uses this method to un-register itself on destruction with its owning Component. More...
 
void callbackInitCall ()
 For all parameters that have a callback which has never been called, call it with the default param value. More...
 

Constructor & Destructor Documentation

◆ PythonModule()

jevois::PythonModule::PythonModule ( jevois::VideoMapping const &  m)

Constructor needs the full path to a Python source code file.

Definition at line 170 of file PythonModule.C.

References jevois::VideoMapping::ispython, LFATAL, jevois::VideoMapping::modulename, and jevois::VideoMapping::sopath().

◆ ~PythonModule()

jevois::PythonModule::~PythonModule ( )
virtual

Virtual destructor for safe inheritance.

Definition at line 202 of file PythonModule.C.

Member Function Documentation

◆ parseSerial()

void jevois::PythonModule::parseSerial ( std::string const &  str,
std::shared_ptr< UserInterface s 
)
overridevirtual

Receive a string from a serial port which contains a user command.

Reimplemented from jevois::Module.

Definition at line 221 of file PythonModule.C.

References jevois::Module::parseSerial().

◆ postUninit()

void jevois::PythonModule::postUninit ( )
overridevirtual

Optionally call uninit() python module function, if implemented.

Reimplemented from jevois::Component.

Definition at line 195 of file PythonModule.C.

◆ process() [1/2]

void jevois::PythonModule::process ( InputFrame &&  inframe,
OutputFrame &&  outframe 
)
overridevirtual

Processing function, version that receives a frame from camera and sends a frame out over USB.

Reimplemented from jevois::Module.

Definition at line 206 of file PythonModule.C.

◆ process() [2/2]

void jevois::PythonModule::process ( InputFrame &&  inframe)
overridevirtual

Processing function, version that receives a frame from camera and does not use USB.

Reimplemented from jevois::Module.

Definition at line 214 of file PythonModule.C.

◆ supportedCommands()

void jevois::PythonModule::supportedCommands ( std::ostream &  os)
overridevirtual

Human-readable description of this Module's supported custom commands.

Reimplemented from jevois::Module.

Definition at line 233 of file PythonModule.C.

References jevois::Module::supportedCommands().

Friends And Related Function Documentation

◆ pythonModuleSetEngine()

void pythonModuleSetEngine ( jevois::Engine e)
related

Initialize Python, numpy, and allow python modules to send serial outputs through the JeVois Engine.

This command is not for common use, only Engine should use it.


The documentation for this class was generated from the following files: