JeVois
1.21
JeVois Smart Embedded Machine Vision Toolkit
|
|
#include <jevois/Core/Engine.H>
JeVois processing engine - gets images from camera sensor, processes them, and sends results over USB.
The Engine is orchestrating the execution of vision processing software. It is a Manager, i.e., it is the root of a hierarchy of Component objects and it handles access to their Parameter settings and their construction, init(), unInit(), and destruction. The component hierarchy consists of Engine at the root, then one Module which is selected by the user at runtime, e.g., by selecting a given video format on video camera software running on a host computer connected to the JeVois hardware. The Module may then contain an arbitrarily complex hierarchy of Component objects with Parameter settings in them. Module derives from Component and thus may also have its own Parameter settings.
Engine contains the following basic elements:
The main loop of Engine runs until the user decides to quit, and basically goes through the following steps:
Public Member Functions | |
Engine (std::string const &instance) | |
Constructor. | |
Engine (int argc, char const *argv[], std::string const &instance) | |
Constructor with command-line parsing. | |
~Engine () | |
Destructor. | |
void | reloadVideoMappings () |
Re-load video mappings from videomappings.cfg. | |
VideoMapping const & | findVideoMapping (unsigned int oformat, unsigned int owidth, unsigned int oheight, float oframespersec) const |
Find the VideoMapping that has the given output specs, or throw if not found. | |
VideoMapping const & | getCurrentVideoMapping () const |
Get the current video mapping. | |
size_t | numVideoMappings () const |
Return the number of video mappings. | |
VideoMapping const & | getVideoMapping (size_t idx) const |
Allow access to our video mappings which are parsed from file at construction. | |
size_t | getVideoMappingIdx (unsigned int iformat, unsigned int iframe, unsigned int interval) const |
Get the video mapping index for a given UVC iformat, iframe and interval. | |
VideoMapping const & | getDefaultVideoMapping () const |
Allow access to the default video mapping. | |
size_t | getDefaultVideoMappingIdx () const |
Allow access to the default video mapping index. | |
void | foreachVideoMapping (std::function< void(VideoMapping const &m)> &&func) |
Run a function on every video mapping. | |
void | requestSetFormat (int idx) |
Use this to request a format change from within process() | |
void | quit () |
Terminate the program. | |
void | reboot () |
Request a reboot. | |
void | setFormat (size_t idx) |
Callback for when the user selects a new output video format. | |
void | streamOn () |
Start streaming on video from camera, processing, and USB. | |
void | streamOff () |
Stop streaming on video from camera, processing, and USB. | |
int | mainLoop () |
Main loop: grab, process, send over USB. Should be called by main application thread. | |
void | sendSerial (std::string const &str, bool islog=false) |
Send a string to all serial ports. | |
std::shared_ptr< Module > | module () const |
Get a pointer to our current module (may be null) | |
std::shared_ptr< Camera > | camera () const |
Get a pointer to our Camera (may be null, especially if not using a camera but, eg, movie input) | |
void | drawCameraGUI () |
Draw all camera controls into our GUI. | |
CameraCalibration | loadCameraCalibration (std::string const &stem="calibration", bool do_throw=false) |
Helper to load an OpenCV camera matrix and distortion coeffs for the current running module. | |
void | saveCameraCalibration (CameraCalibration const &calib, std::string const &stem="calibration") |
Helper to save an OpenCV camera matrix and distortion coeffs for the current running module. | |
void | registerPythonComponent (Component *comp, void *pyinst) |
Register a component as linked to some python code, used by dynamic params created in python. | |
void | unRegisterPythonComponent (Component *comp) |
Unregister a component as linked to some python code, used by dynamic params created in python. | |
Component * | getPythonComponent (void *pyinst) const |
Get the component registered with a given python instance. | |
void | reportError (std::string const &err) |
void | clearErrors () |
Clear all errors currently displayed in the JeVois-Pro GUI. | |
void | nextDemo () |
When in demo mode, switch to next demo. | |
void | abortDemo () |
When in demo mode, abort demo mode. | |
Public Member Functions inherited from jevois::Manager | |
Manager (std::string const &instance="TheManager") | |
Constructor without command-line args. | |
Manager (int argc, char const *argv[], std::string const &instance="TheManager") | |
Constructor. | |
void | setCommandLineArgs (int argc, char const *argv[]) |
Set the command-line arguments, call this before start() if args were not passed at construction. | |
virtual | ~Manager () |
Destructor. | |
template<class Comp , typename... Args> | |
std::shared_ptr< Comp > | addComponent (std::string const &instanceName, Args &&...args) |
Pseudo-constructor: construct a top-level Component. | |
template<class Comp , typename... Args> | |
std::shared_ptr< Comp > | addSubComponent (std::string const &instanceName, Args &&...args)=delete |
Use addComponent() on the Manager as opposed to jevois::Component::addSubComponent() | |
template<class Comp > | |
void | removeComponent (std::shared_ptr< Comp > &component) |
Remove a top-level Component from the Manager, by shared_ptr. | |
template<class Comp > | |
void | removeSubComponent (std::shared_ptr< Comp > &component)=delete |
Use removeComponent() on the Manager as opposed to jevois::Component::removeSubComponent() | |
void | removeComponent (std::string const &instanceName, bool warnIfNotFound=true) |
Remove a top-level Component from the Manager, by instance name. | |
void | removeSubComponent (std::string const &instanceName, bool warnIfNotFound)=delete |
Use removeComponent() on the Manager as opposed to jevois::Component::removeSubComponent() | |
template<class Comp = jevois::Component> | |
std::shared_ptr< Comp > | getComponent (std::string const &instanceName) const |
Get a top-level component by instance name. | |
template<class Comp > | |
std::shared_ptr< Comp > | getSubComponent (std::string const &instanceName) const =delete |
Use getComponent() on the Manager as opposed to jevois::Component::getSubComponent() | |
std::vector< std::string > const & | remainingArgs () const |
Get the remaining arguments that were not parsed by the command line. | |
Public Member Functions inherited from jevois::Component | |
Component (std::string const &instance) | |
Constructor. | |
virtual | ~Component () |
Virtual destructor for safe inheritance. | |
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. | |
template<class Comp > | |
void | removeSubComponent (std::shared_ptr< Comp > &component) |
Remove a sub-Component from this Component, by shared_ptr. | |
void | removeSubComponent (std::string const &instance, bool warnIfNotFound=true) |
Remove a sub-Component from this Component, by instance name. | |
template<class Comp = jevois::Component> | |
std::shared_ptr< Comp > | getSubComponent (std::string const &instance) const |
Get a sub-component by instance name. | |
bool | isTopLevel () const |
Returns true if this component is top-level, i.e., its parent is jevois::Manager. | |
bool | initialized () const |
Has this component been initialized yet? | |
std::string const & | className () const |
The class name of this component. | |
std::string const & | instanceName () const |
The instance name of this component. | |
template<typename T > | |
std::vector< std::string > | setParamVal (std::string const ¶mdescriptor, T const &val) |
Set a parameter value. | |
template<typename T > | |
void | setParamValUnique (std::string const ¶mdescriptor, T const &val) |
Set a parameter value, simple version assuming only one parameter match. | |
template<typename T > | |
std::vector< std::pair< std::string, T > > | getParamVal (std::string const ¶mdescriptor) const |
Get parameter(s) value(s) by descriptor. | |
template<typename T > | |
T | getParamValUnique (std::string const ¶mdescriptor) const |
Get a parameter value, simple version assuming only one parameter match. | |
std::vector< std::string > | setParamString (std::string const ¶mdescriptor, std::string const &val) |
Set a parameter value, by string. | |
void | setParamStringUnique (std::string const ¶mdescriptor, std::string const &val) |
Set a parameter value by string, simple version assuming only one parameter match. | |
std::vector< std::pair< std::string, std::string > > | getParamString (std::string const ¶mdescriptor) const |
Get a parameter value, by string. | |
std::string | getParamStringUnique (std::string const ¶mdescriptor) const |
Get a parameter value by string, simple version assuming only one parameter match. | |
void | freezeParam (std::string const ¶mdescriptor, bool doit) |
Freeze/unfreeze a parameter, by name, see ParameterBase::freeze() | |
void | freezeAllParams (bool doit) |
Freeze all parameters. | |
std::string | descriptor () const |
Get our full descriptor (including all parents) as [Instancename]:[...]:[...]. | |
void | setParamsFromFile (std::string const &filename) |
Set some parameters from a file. | |
std::istream & | setParamsFromStream (std::istream &is, std::string const &absfile) |
Set some parameters from an open stream. | |
virtual void | paramInfo (std::shared_ptr< UserInterface > s, std::map< std::string, std::string > &categs, bool skipFrozen, std::string const &cname="", std::string const &pfx="") |
Get machine-oriented descriptions of all parameters. | |
void | foreachParam (std::function< void(std::string const &compname, ParameterBase *p)> func, std::string const &cname="") |
Run a function on every param we hold. | |
template<typename T > | |
std::shared_ptr< DynamicParameter< T > > | addDynamicParameter (std::string const &name, std::string const &description, T const &defaultValue, ParameterCategory const &category) |
Add a new parameter after the Component has already been constructed. | |
template<typename T , template< typename > class ValidValuesSpec> | |
std::shared_ptr< DynamicParameter< T > > | addDynamicParameter (std::string const &name, std::string const &description, T const &defaultValue, ValidValuesSpec< T > const &validValuesSpec, ParameterCategory const &category) |
Add a new parameter after the Component has already been constructed. | |
template<typename T > | |
void | setDynamicParameterCallback (std::string const &name, std::function< void(T const &)> cb, bool callnow=true) |
Register a callback with a previously created dynamic parameter. | |
void | removeDynamicParameter (std::string const &name, bool throw_if_not_found=true) |
Remove a previously added dynamic parameter. | |
void | setPath (std::string const &path) |
Assign a filesystem path to this component. | |
std::filesystem::path | absolutePath (std::filesystem::path const &path="") |
If given path is relative (not starting with /), prepend the Component path to it. | |
Public Member Functions inherited from jevois::ParameterRegistry | |
virtual | ~ParameterRegistry () |
Virtual destructor for safe inheritance. | |
Protected Member Functions | |
void | runScriptFromFile (std::string const &filename, std::shared_ptr< UserInterface > ser, bool throw_no_file) |
Run a script from file. | |
void | onParamChange (engine::serialdev const ¶m, std::string const &newval) override |
Parameter callback. | |
void | onParamChange (engine::usbserialdev const ¶m, std::string const &newval) override |
Parameter callback. | |
void | onParamChange (engine::cpumode const ¶m, engine::CPUmode const &newval) override |
Parameter callback. | |
void | onParamChange (engine::cpumax const ¶m, unsigned int const &newval) override |
Parameter callback. | |
void | onParamChange (engine::videoerrors const ¶m, bool const &newval) override |
Parameter callback. | |
void | onParamChange (engine::gui const ¶m, bool const &newval) override |
Parameter callback. | |
void | onParamChange (engine::cpumaxl const ¶m, unsigned int const &newval) override |
Parameter callback. | |
void | onParamChange (engine::cpumodel const ¶m, engine::CPUmode const &newval) override |
Parameter callback. | |
void | onParamChange (engine::demomode const ¶m, float const &newval) override |
Parameter callback. | |
void | preInit () override |
Override of Manager::preInit() | |
void | postInit () override |
Override of Manager::postInit() | |
bool | parseCommand (std::string const &str, std::shared_ptr< UserInterface > s, std::string const &pfx="") |
Parse a user command received over serial port. | |
Protected Member Functions inherited from jevois::Manager | |
void | onParamChange (manager::loglevel const ¶m, manager::LogLevel const &newval) override |
Parameter callback. | |
void | onParamChange (manager::tracelevel const ¶m, unsigned int const &newval) override |
Parameter callback. | |
void | preInit () override |
Calls parseCommandLine() | |
void | postInit () override |
Checks for the –help flag. | |
void | constructHelpMessage (std::ostream &out) const |
Constructs a help message from all parameters in the model, and outputs it to 'out'. | |
void | printHelpMessage () const |
Constructs a help message and tries to send it to /usr/bin/less. | |
Protected Member Functions inherited from jevois::Component | |
virtual void | preUninit () |
Called before all sub-Components are uninit()ed. | |
virtual void | postUninit () |
Called after all sub-Components are uninit()ed. | |
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. | |
void | removeParameter (ParameterBase *const param) |
The Parameter class uses this method to un-register itself on destruction with its owning Component. | |
void | callbackInitCall () |
For all parameters that have a callback which has never been called, call it with the default param value. | |
Protected Attributes | |
size_t | itsDefaultMappingIdx |
Index of default mapping. | |
std::vector< VideoMapping > | itsMappings |
All our mappings from videomappings.cfg. | |
VideoMapping | itsCurrentMapping |
Current mapping, may not match any in itsMappings if setmapping2 used. | |
std::shared_ptr< VideoInput > | itsCamera |
Our camera. | |
std::shared_ptr< IMU > | itsIMU |
std::shared_ptr< VideoOutput > | itsGadget |
Our IMU. | |
std::unique_ptr< DynamicLoader > | itsLoader |
Our module loader. | |
std::shared_ptr< Module > | itsModule |
Our current module. | |
std::atomic< bool > | itsRunning |
True when we are running. | |
std::atomic< bool > | itsStreaming |
True when we are streaming video. | |
std::atomic< bool > | itsStopMainLoop |
Flag used to stop the main loop. | |
std::timed_mutex | itsMtx |
Mutex to protect our internals. | |
Related Symbols | |
(Note that these are not member symbols.) | |
size_t | frameNum () |
Get the current video processing frame number. | |
JEVOIS_DECLARE_PARAMETER (cameradev, std::string, "Camera device name (if starting with /dev/v...), or movie " "file name (e.g., movie.mpg) or image sequence (e.g., im%02d.jpg, to read frames " "im00.jpg, im01.jpg, etc).", JEVOIS_CAMERA_DEFAULT, ParamCateg) | |
Parameter. | |
JEVOIS_DECLARE_PARAMETER (camerasens, CameraSensor, "Camera sensor. Users would usually not set this parameter " "manually, it is set through boot-time configuration.", JEVOIS_CAMERASENS_DEFAULT, CameraSensor_Values, ParamCateg) | |
Parameter. | |
JEVOIS_DECLARE_PARAMETER (cameralens, CameraLens, "Camera lens. Users should usually not set this parameter " "using the global JeVois params.cfg config file.", CameraLens::standard, CameraLens_Values, ParamCateg) | |
Parameter. | |
JEVOIS_DECLARE_PARAMETER (cameranbuf, unsigned int, "Number of video input (camera) buffers, or 0 for automatic.", 0, ParamCateg) | |
Parameter. | |
JEVOIS_DECLARE_PARAMETER (gadgetdev, std::string, "Gadget device name. This is used on platform hardware only. " "On host hardware, a display window will be used unless gadgetdev is None (useful " "for benchmarking) or is a file stem for a movie file that does not start with /dev/ " "(and which should contain a printf-style directive for a single int argument, " "the movie number).", JEVOIS_GADGET_DEFAULT, ParamCateg) | |
Parameter. | |
JEVOIS_DECLARE_PARAMETER (gadgetnbuf, unsigned int, "Number of video output (USB video) buffers, or 0 for auto", 0, ParamCateg) | |
Parameter. | |
JEVOIS_DECLARE_PARAMETER (videomapping, int, "Index of Video Mapping to use, or -1 to use the default mapping. " "Note that this parameter is only available when parsing command-line arguments. " "At runtime, the setmapping command should be used instead.", -1, ParamCateg) | |
Parameter. | |
JEVOIS_DECLARE_PARAMETER (serialmonitors, bool, "If true, serial port monitors will be enabled " "in the GUI, which can be used to peek at serial communications not " "directed to the console. Can be turned off at start time (e.g., in the " "global JeVois params.cfg) as there is some small CPU cost to it.", true, ParamCateg) | |
Parameter. | |
JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK (serialdev, std::string, "Hardware (4-pin connector) serial device name, " "or 'stdio' to use the console, or empty for no hardware serial port", JEVOIS_SERIAL_DEFAULT, ParamCateg) | |
Parameter. | |
JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK (usbserialdev, std::string, "Over-the-USB serial device name, or empty", JEVOIS_USBSERIAL_DEFAULT, ParamCateg) | |
Parameter. | |
JEVOIS_DECLARE_PARAMETER (camreg, bool, "Enable raw access to camera registers through setcamreg and getcamreg", false, ParamCateg) | |
Parameter. | |
JEVOIS_DECLARE_PARAMETER (imureg, bool, "Enable raw access to IMU registers through setimureg and getimureg", false, ParamCateg) | |
Parameter. | |
JEVOIS_DECLARE_PARAMETER (camturbo, bool, "Enable camera turbo mode by relaxing the need for DMA-coherent video " "buffer memory. This can accelerate severalfolds access to the captured image data, but " "it may also yield stripe artifacts with some modules, such as PassThrough. The stripes " "are pieces of incorrect data in the cache. You should experiment with each particular " "module. Turbo mode is not recommended for any production-grade application.", false, ParamCateg) | |
Parameter. | |
JEVOIS_DEFINE_ENUM_CLASS (SerPort,(None)(All)(Hard)(USB)) | |
Enum for Parameter. | |
JEVOIS_DECLARE_PARAMETER (serlog, SerPort, "Show log and debug messages on selected serial port(s)", SerPort::None, SerPort_Values, ParamCateg) | |
Parameter. | |
JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK (videoerrors, bool, "Show any machine vision module errors (exceptions) " "in the video stream. Only takes effect if streaming video to USB.", true, ParamCateg) | |
Parameter. | |
JEVOIS_DECLARE_PARAMETER (serout, SerPort, "Send module serial messages to selected serial port(s)", SerPort::None, SerPort_Values, ParamCateg) | |
Parameter. | |
JEVOIS_DEFINE_ENUM_CLASS (CPUmode,(PowerSave)(Conservative)(OnDemand)(Interactive)(Performance)) | |
Enum for Parameter. | |
JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK (cpumode, CPUmode, "CPU frequency modulation mode" " for A73 big cores", CPUmode::Performance, CPUmode_Values, ParamCateg) | |
Parameter. | |
JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK (cpumodel, CPUmode, "CPU frequency modulation mode for A53 little cores", CPUmode::Performance, CPUmode_Values, ParamCateg) | |
Parameter. | |
JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK (cpumax, unsigned int, "CPU maximum frequency in MHz" ". To enable overclock frequencies above 2208 MHz, you need to first edit " "/boot/env.txt and change max_freq_a73, then reboot. Use with caution!", 2208, { 500, 667, 1000, 1200, 1398, 1512, 1608, 1704, 1800, 1908, 2016, 2100, 2208, 2304, 2400 }, ParamCateg) | |
Parameter. | |
JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK (cpumaxl, unsigned int, "CPU maximum frequency in MHz, for A53 little cores. " "To enable overclock frequencies above 1800 MHz, you need to first edit " "/boot/env.txt and change max_freq_a53, then reboot. Use with caution!", 1800, { 500, 667, 1000, 1200, 1398, 1512, 1608, 1704, 1800, 1908, 2016, 2100, 2208 }, ParamCateg) | |
Parameter. | |
JEVOIS_DECLARE_PARAMETER (multicam, bool, "Allow up to 3 JeVois cameras on one USB bus. Enabling this " "reduces the amount of USB bandwidth used by each JeVois camera, from 3kb " "per USB isochronous microframe to 1kb. All 3 JeVois cameras must have this " "option enabled, and the JeVois linux kernel module should also have " "been loaded with multicam on.", false, ParamCateg) | |
Parameter. | |
JEVOIS_DECLARE_PARAMETER (quietcmd, bool, "When true, do not issue a message 'OK' after every correct command " "received at the command-line interface. Recommended for advanced users only.", false, ParamCateg) | |
Parameter. | |
JEVOIS_DECLARE_PARAMETER (python, bool, "When true, enable support for modules written in Python. Otherwise, " "attempting to load a python module will throw an exception. Disabling python saves " "a lot of memory and may be useful when using C++ modules that run large deep neural " "networks.", true, ParamCateg) | |
Parameter. | |
JEVOIS_DECLARE_PARAMETER (serlimit, size_t, "Maximum number of serial messages that can be sent by a module " "using sendSerial(), for each video frame, or 0 for no limit. Any message sent by " "the module beyond the first serlimit ones will be dropped. This is useful to avoid " "overloading the serial link, for example in case one is running a ArUco detector and " "a large number of ArUco tags are present in the field of view of JeVois.", 0, ParamCateg) | |
Parameter. | |
JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK (gui, bool, "Use a graphical user interface instead of plain display " "when true", true, ParamCateg) | |
Parameter. | |
JEVOIS_DECLARE_PARAMETER (conslock, bool, "Lock the console and capture the keyboard and mouse to avoid " "interference, only effective on JeVois-Pro Platform, otherwise ignored. Set conslock " "to false if you are experiencing hard crashes and want to run jevoispro-daemon in gdb.", true, ParamCateg) | |
Parameter. | |
JEVOIS_DECLARE_PARAMETER (watchdog, double, "Timeout in seconds after which we kill this process if the main loop " "is stuck somehow, or 0.0 for no watchdog", 10.0, ParamCateg) | |
Parameter. | |
JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK (demomode, float, "Show a demonstration of some available JeVois-Pro " "machine vision modules, cycling to the next modules after a number " "of seconds specified by this parameter (or 0.0 for no demo mode).", 0.0F, ParamCateg) | |
Parameter. | |
Related Symbols inherited from jevois::Manager | |
JEVOIS_DECLARE_PARAMETER (help, bool, "Print this help message", false, ParamCateg) | |
Parameter. | |
JEVOIS_DEFINE_ENUM_CLASS (LogLevel,(fatal)(error)(info)(debug)) | |
Enum for Parameter. | |
JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK (loglevel, LogLevel, "Set the minimum log level to display", LogLevel::info, LogLevel_Values, ParamCateg) | |
Parameter. | |
JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK (tracelevel, unsigned int, "Set the minimum trace level to display", 0, ParamCateg) | |
Parameter. | |
JEVOIS_DECLARE_PARAMETER (nickname, std::string, "Nickname associated with this camera, useful when multiple " "JeVois cameras are connected to a same USB bus", "jevois", ParamCateg) | |
Parameter. | |
jevois::Engine::Engine | ( | std::string const & | instance | ) |
Constructor.
Definition at line 221 of file Engine.C.
References jevois::async_little(), and JEVOIS_TRACE.
jevois::Engine::Engine | ( | int | argc, |
char const * | argv[], | ||
std::string const & | instance | ||
) |
Constructor with command-line parsing.
Definition at line 239 of file Engine.C.
References jevois::async_little(), and JEVOIS_TRACE.
jevois::Engine::~Engine | ( | ) |
Destructor.
Definition at line 830 of file Engine.C.
References JEVOIS_TIMED_LOCK, JEVOIS_TRACE, jevois::logSetEngine(), and jevois::warnAndIgnoreException().
void jevois::Engine::abortDemo | ( | ) |
When in demo mode, abort demo mode.
Definition at line 604 of file Engine.C.
Referenced by jevois::GUIhelper::endFrame().
std::shared_ptr< jevois::Camera > jevois::Engine::camera | ( | ) | const |
void jevois::Engine::clearErrors | ( | ) |
Clear all errors currently displayed in the JeVois-Pro GUI.
In the JevoisPro GUI, errors reported via reportError() remain displayed for a few seconds, but sometimes we want to clear them right away, e.g., after DNN pipeline threw, if the user selects another one, we want the previous error to disappear immediately since it is not applicable anymore. When the JeVois-Pro GUI is not used, this has no effect.
Definition at line 1400 of file Engine.C.
Referenced by jevois::dnn::Pipeline::onParamChange().
void jevois::Engine::drawCameraGUI | ( | ) |
Draw all camera controls into our GUI.
Definition at line 2859 of file Engine.C.
Referenced by jevois::GUIhelper::drawCamCtrls().
jevois::VideoMapping const & jevois::Engine::findVideoMapping | ( | unsigned int | oformat, |
unsigned int | owidth, | ||
unsigned int | oheight, | ||
float | oframespersec | ||
) | const |
Find the VideoMapping that has the given output specs, or throw if not found.
Definition at line 1586 of file Engine.C.
References jevois::fccstr(), LFATAL, and jevois::VideoMapping::match().
void jevois::Engine::foreachVideoMapping | ( | std::function< void(VideoMapping const &m)> && | func | ) |
Run a function on every video mapping.
The first mapping your function will be called on is for mapping with index 0, and so on until index numVideoMappings()-1. If your function throws, we report the exception and then ignore it, then we move on to the next mapping.
Definition at line 1578 of file Engine.C.
References jevois::warnAndIgnoreException().
Referenced by jevois::GUIhelper::runNewModule().
jevois::VideoMapping const & jevois::Engine::getCurrentVideoMapping | ( | ) | const |
Get the current video mapping.
Note that the current mapping may not have an entry in our list of mappings obtained from videomappings.cfg, if the current one was set on the fly by the setmapping2 CLI command.
Definition at line 1522 of file Engine.C.
Referenced by jevois::GUIhelper::drawInfo(), and jevois::GUIhelper::resetstate().
jevois::VideoMapping const & jevois::Engine::getDefaultVideoMapping | ( | ) | const |
Allow access to the default video mapping.
Definition at line 1570 of file Engine.C.
Referenced by jevois::Gadget::Gadget().
size_t jevois::Engine::getDefaultVideoMappingIdx | ( | ) | const |
jevois::Component * jevois::Engine::getPythonComponent | ( | void * | pyinst | ) | const |
jevois::VideoMapping const & jevois::Engine::getVideoMapping | ( | size_t | idx | ) | const |
size_t jevois::Engine::getVideoMappingIdx | ( | unsigned int | iformat, |
unsigned int | iframe, | ||
unsigned int | interval | ||
) | const |
Get the video mapping index for a given UVC iformat, iframe and interval.
Definition at line 1539 of file Engine.C.
References LFATAL, jevois::VideoMapping::ofps, jevois::VideoMapping::uvcformat, jevois::VideoMapping::uvcframe, and jevois::VideoMapping::uvcToFps().
jevois::CameraCalibration jevois::Engine::loadCameraCalibration | ( | std::string const & | stem = "calibration" , |
bool | do_throw = false |
||
) |
Helper to load an OpenCV camera matrix and distortion coeffs for the current running module.
If do_throw is false, just report an error and provide identity defaults if calibration mot found. This would typically be called in preInit() or postInit() of any module that will need the calibration parameters. Note: for thread safety, engine should be locked; calling this inside Module::process() is safe.
Definition at line 1470 of file Engine.C.
References jevois::CameraCalibration::h, h, JEVOIS_SHARE_PATH, jevois::CameraCalibration::lens, LFATAL, LINFO, jevois::CameraCalibration::load(), jevois::CameraCalibration::sensor, and jevois::CameraCalibration::w.
int jevois::Engine::mainLoop | ( | ) |
Main loop: grab, process, send over USB. Should be called by main application thread.
Definition at line 1095 of file Engine.C.
References jevois::UserInterface::Hard, JEVOIS_TIMED_LOCK, JEVOIS_TRACE, JEVOIS_VERSION_STRING, JEVOISPRO_FMT_GUI, LDEBUG, jevois::StdModule::sendSerialMarkStart(), jevois::StdModule::sendSerialMarkStop(), jevois::stringStartsWith(), success, and jevois::warnAndIgnoreException().
Referenced by main().
std::shared_ptr< jevois::Module > jevois::Engine::module | ( | ) | const |
Get a pointer to our current module (may be null)
Definition at line 1458 of file Engine.C.
Referenced by jevois::GUIhelper::drawConsole(), jevois::GUIhelper::drawInfo(), and jevois::GUIhelper::drawParameters().
void jevois::Engine::nextDemo | ( | ) |
When in demo mode, switch to next demo.
Definition at line 600 of file Engine.C.
Referenced by jevois::GUIhelper::endFrame().
size_t jevois::Engine::numVideoMappings | ( | ) | const |
|
overrideprotected |
Parameter callback.
|
overrideprotected |
Parameter callback.
|
overrideprotected |
Parameter callback.
|
overrideprotected |
Parameter callback.
|
overrideprotected |
Parameter callback.
|
overrideprotected |
Parameter callback.
|
overrideprotected |
Parameter callback.
|
overrideprotected |
Parameter callback.
|
overrideprotected |
Parameter callback.
|
protected |
Parse a user command received over serial port.
Throw upon receiving an incorrect command (eg, bad parameter value), return true if success, return false if command was not recognized and should be tried by Module. pfx is an optional prefix which will be added to all produced messages or errors.
Definition at line 1971 of file Engine.C.
References jevois::getSysInfoCPU(), jevois::getSysInfoMem(), jevois::getSysInfoVersion(), JEVOIS_CUSTOM_DNN_PATH, JEVOIS_CUSTOM_DNN_URL, JEVOIS_USBSD_SYS, JEVOIS_VERSION_STRING, JEVOISPRO_FMT_GUI, LDEBUG, jevois::split(), and jevois::system().
|
overrideprotectedvirtual |
Override of Manager::postInit()
Reimplemented from jevois::Component.
Definition at line 641 of file Engine.C.
References jevois::getFileString(), JEVOIS_ENGINE_INIT_SCRIPT, JEVOIS_TIMED_LOCK, LERROR, LINFO, jevois::logSetEngine(), jevois::Manager::postInit(), jevois::sensorHasIMU(), jevois::python::setEngine(), jevois::stringStartsWith(), and jevois::warnAndIgnoreException().
|
overrideprotectedvirtual |
Override of Manager::preInit()
Reimplemented from jevois::Component.
Definition at line 617 of file Engine.C.
References JEVOIS_CONFIG_PATH, JEVOIS_MODULE_PARAMS_FILENAME, and jevois::Manager::preInit().
void jevois::Engine::quit | ( | ) |
Terminate the program.
Definition at line 1869 of file Engine.C.
Referenced by jevois::GUIhelper::drawMenuBar(), and jevois::GUIhelper::startFrame().
void jevois::Engine::reboot | ( | ) |
void jevois::Engine::registerPythonComponent | ( | jevois::Component * | comp, |
void * | pyinst | ||
) |
Register a component as linked to some python code, used by dynamic params created in python.
Use with extreme caution to guarantee thread safety and object lifetime since we just use raw pointers here
Definition at line 2996 of file Engine.C.
References jevois::Component::instanceName(), LDEBUG, and LFATAL.
void jevois::Engine::reloadVideoMappings | ( | ) |
Re-load video mappings from videomappings.cfg.
Mappings are automatically loaded on startup so this should only be used if the file has been modified and the mappings need to be refreshed. Note that this will not refresh the available resolutions for USB output, which requires a full reboot to re-initialize the kernel Gadget module. Also beware of possible state inconsistency (e.g., if external code is holding a reference previously returned by findVideoMapping(). So, use with caution. Basically, only GUIhelper should use this.
Definition at line 628 of file Engine.C.
References LINFO.
Referenced by jevois::GUIhelper::compileModule(), and jevois::GUIhelper::runNewModule().
void jevois::Engine::reportError | ( | std::string const & | err | ) |
Try to minimize the use of this function, and normally use LERROR() or LFATAL() instead. Currently the only use is in jevois::dnn::Pipeline, to report parameters set in the zoo file but not used by the pipeline, as issuing an LFATAL() for that may be too strict, but issuing an LERROR() may go un-noticed since the pipeline is still running just fine.
Definition at line 1391 of file Engine.C.
References LERROR.
void jevois::Engine::requestSetFormat | ( | int | idx | ) |
Use this to request a format change from within process()
This should only be used on JeVois-Pro in GUI mode. The engine is locked up hence and setFormat() cannot be called from within a Module's process function, to avoid possible disasters of changing format while we process. Modules or the GUI can use requestSetFormat() to request a format change in between two calls to process(). Note special values: -1 to just reload the current format (e.g., after editing code), -2 does nothing.
Definition at line 932 of file Engine.C.
References JEVOIS_TRACE.
Referenced by jevois::GUIhelper::runNewModule().
|
protected |
Run a script from file.
The filename should be absolute. The file should have any of the commands supported by Engine, one per line. Filename should be relative to the current module's path.
Definition at line 2781 of file Engine.C.
References jevois::UserInterface::GUI, jevois::UserInterface::Hard, LFATAL, jevois::strip(), jevois::UserInterface::USB, and jevois::warnAndIgnoreException().
void jevois::Engine::saveCameraCalibration | ( | jevois::CameraCalibration const & | calib, |
std::string const & | stem = "calibration" |
||
) |
Helper to save an OpenCV camera matrix and distortion coeffs for the current running module.
Note: for thread safety, engine should be locked; calling this inside Module::process() is safe.
Definition at line 1508 of file Engine.C.
References jevois::CameraCalibration::h, JEVOIS_SHARE_PATH, jevois::CameraCalibration::lens, LINFO, jevois::CameraCalibration::save(), jevois::CameraCalibration::sensor, jevois::to_string(), and jevois::CameraCalibration::w.
void jevois::Engine::sendSerial | ( | std::string const & | str, |
bool | islog = false |
||
) |
Send a string to all serial ports.
serlimit
; only up to serlimit
messages will be sent for a given video frame. This is useful to avoid overloading the serial link, for example in cases one is running a ArUco detector and a large number of ArUco tags are present in the field of view of JeVois. Definition at line 1346 of file Engine.C.
References jevois::UserInterface::GUI, jevois::UserInterface::Hard, jevois::UserInterface::USB, and jevois::warnAndIgnoreException().
Referenced by jevois::Module::sendSerial().
void jevois::Engine::setFormat | ( | size_t | idx | ) |
Callback for when the user selects a new output video format.
Here, we stop streaming, nuke any current processing module, set the camera format, set the gadget output format, load the new processing module, and start streaming again. The given VideoMapping will typically be obtained using findVideoMapping() from output specs received over the USB link.
Definition at line 939 of file Engine.C.
References JEVOIS_TIMED_LOCK, JEVOIS_TRACE, LDEBUG, and LFATAL.
void jevois::Engine::streamOff | ( | ) |
Stop streaming on video from camera, processing, and USB.
Definition at line 911 of file Engine.C.
References JEVOIS_TIMED_LOCK, JEVOIS_TRACE, and LDEBUG.
void jevois::Engine::streamOn | ( | ) |
Start streaming on video from camera, processing, and USB.
Definition at line 900 of file Engine.C.
References JEVOIS_TIMED_LOCK, and JEVOIS_TRACE.
Referenced by main().
void jevois::Engine::unRegisterPythonComponent | ( | Component * | comp | ) |
Unregister a component as linked to some python code, used by dynamic params created in python.
Use with extreme caution to guarantee thread safety and object lifetime since we just use raw pointers here
Definition at line 3006 of file Engine.C.
References jevois::Component::instanceName(), and LDEBUG.
|
related |
Get the current video processing frame number.
The Engine maintains a master frame counter that is incremented on each call to a Module's process(), whether or not the call succeeds. The counter is not incremented when a module has not been loaded (e.g., failed to load). The counter is reset to zero each time a new module is loaded.
This is implemented as a free function so that anyone can access it:
It is thread-safe. Programmer note: the implementation is in Engine.C since Engine is the one that manages the counter. It is declared here so that users don't have to include Engine.H
|
related |
Parameter.
|
related |
Parameter.
|
related |
Parameter.
|
related |
Parameter.
|
related |
Parameter.
|
related |
Parameter.
|
related |
Parameter.
|
related |
Parameter.
|
related |
Parameter.
|
related |
Parameter.
|
related |
Parameter.
|
related |
Parameter.
|
related |
Parameter.
|
related |
Parameter.
|
related |
Parameter.
|
related |
Parameter.
|
related |
Parameter.
|
related |
Parameter.
|
related |
Parameter.
|
related |
Parameter.
|
related |
Parameter.
|
related |
Parameter.
|
related |
Parameter.
|
related |
Parameter.
|
related |
Parameter.
|
related |
Parameter.
|
related |
Parameter.
|
related |
Parameter.
|
related |
Enum for Parameter.
|
related |
Enum for Parameter.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
mutableprotected |
|
protected |
|
protected |
|
protected |