|
JeVoisBase
1.23
JeVois Smart Embedded Machine Vision Toolkit Base Modules
|
|
Abstract base class for an object recognition component. More...
#include <jevoisbase/Components/ObjectRecognition/ObjectRecognition.H>


Public Types | |
| typedef std::vector< tiny_dnn::float_t, tiny_dnn::aligned_allocator< tiny_dnn::float_t, 64 > > | vec_t |
| Type used by tiny-dnn for the results: | |
Public Member Functions | |
| ObjectRecognitionBase (std::string const &instance) | |
| Constructor. | |
| virtual | ~ObjectRecognitionBase () |
| Virtual destructor for safe inheritance. | |
| virtual void | define ()=0 |
| Define the network structure. | |
| virtual tiny_dnn::index3d< size_t > | insize () const =0 |
| Get the input size for the current network, useful to prepare inputs to process() | |
| virtual void | train (std::string const &path)=0 |
| Train the network. | |
| virtual vec_t | process (cv::Mat const &img, bool normalize=true)=0 |
| Process an image, results are confidence for each category. | |
| virtual std::string const & | category (size_t idx) const =0 |
| Return the name of a given category (0-based index in the vector of results) | |
Public Member Functions inherited from jevois::Component | |
| Component (std::string const &instance) | |
| virtual | ~Component () |
| std::shared_ptr< Comp > | addSubComponent (std::string const &instance, Args &&...args) |
| void | removeSubComponent (std::shared_ptr< Comp > &component) |
| void | removeSubComponent (std::string const &instance, bool warnIfNotFound=true) |
| std::shared_ptr< Comp > | getSubComponent (std::string const &instance) const |
| bool | isTopLevel () const |
| bool | initialized () const |
| std::string const & | className () const |
| std::string const & | instanceName () const |
| std::vector< std::string > | setParamVal (std::string const ¶mdescriptor, T const &val) |
| void | setParamValUnique (std::string const ¶mdescriptor, T const &val) |
| std::vector< std::pair< std::string, T > > | getParamVal (std::string const ¶mdescriptor) const |
| T | getParamValUnique (std::string const ¶mdescriptor) const |
| std::vector< std::string > | setParamString (std::string const ¶mdescriptor, std::string const &val) |
| void | setParamStringUnique (std::string const ¶mdescriptor, std::string const &val) |
| std::vector< std::pair< std::string, std::string > > | getParamString (std::string const ¶mdescriptor) const |
| std::string | getParamStringUnique (std::string const ¶mdescriptor) const |
| void | freezeParam (std::string const ¶mdescriptor, bool doit) |
| void | freezeAllParams (bool doit) |
| void | hideParam (std::string const ¶mdescriptor, bool doit) |
| void | hideAllParams (bool doit) |
| std::string | descriptor () const |
| void | setParamsFromFile (std::string const &filename) |
| std::istream & | setParamsFromStream (std::istream &is, std::string const &absfile) |
| 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="") |
| void | foreachParam (std::function< void(std::string const &compname, ParameterBase *p)> func, std::string const &cname="") |
| std::shared_ptr< DynamicParameter< T > > | addDynamicParameter (std::string const &name, std::string const &description, T const &defaultValue, ParameterCategory const &category) |
| std::shared_ptr< DynamicParameter< T > > | addDynamicParameter (std::string const &name, std::string const &description, T const &defaultValue, ValidValuesSpec< T > const &validValuesSpec, ParameterCategory const &category) |
| void | setDynamicParameterCallback (std::string const &name, std::function< void(T const &)> cb, bool callnow=true) |
| void | removeDynamicParameter (std::string const &name, bool throw_if_not_found=true) |
| void | setPath (std::string const &path) |
| std::filesystem::path | absolutePath (std::filesystem::path const &path="") |
| std::shared_ptr< Comp > | addSubComponent (std::string const &instance, Args &&...args) |
| void | removeSubComponent (std::shared_ptr< Comp > &component) |
| void | removeSubComponent (std::string const &instance, bool warnIfNotFound=true) |
| std::shared_ptr< Comp > | getSubComponent (std::string const &instance) const |
| bool | isTopLevel () const |
| bool | initialized () const |
| std::string const & | className () const |
| std::string const & | instanceName () const |
| std::vector< std::string > | setParamVal (std::string const ¶mdescriptor, T const &val) |
| void | setParamValUnique (std::string const ¶mdescriptor, T const &val) |
| std::vector< std::pair< std::string, T > > | getParamVal (std::string const ¶mdescriptor) const |
| T | getParamValUnique (std::string const ¶mdescriptor) const |
| std::vector< std::string > | setParamString (std::string const ¶mdescriptor, std::string const &val) |
| void | setParamStringUnique (std::string const ¶mdescriptor, std::string const &val) |
| std::vector< std::pair< std::string, std::string > > | getParamString (std::string const ¶mdescriptor) const |
| std::string | getParamStringUnique (std::string const ¶mdescriptor) const |
| void | freezeParam (std::string const ¶mdescriptor, bool doit) |
| void | freezeAllParams (bool doit) |
| void | hideParam (std::string const ¶mdescriptor, bool doit) |
| void | hideAllParams (bool doit) |
| std::string | descriptor () const |
| void | setParamsFromFile (std::string const &filename) |
| std::istream & | setParamsFromStream (std::istream &is, std::string const &absfile) |
| 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="") |
| void | foreachParam (std::function< void(std::string const &compname, ParameterBase *p)> func, std::string const &cname="") |
| std::shared_ptr< DynamicParameter< T > > | addDynamicParameter (std::string const &name, std::string const &description, T const &defaultValue, ParameterCategory const &category) |
| std::shared_ptr< DynamicParameter< T > > | addDynamicParameter (std::string const &name, std::string const &description, T const &defaultValue, ValidValuesSpec< T > const &validValuesSpec, ParameterCategory const &category) |
| void | setDynamicParameterCallback (std::string const &name, std::function< void(T const &)> cb, bool callnow=true) |
| void | removeDynamicParameter (std::string const &name, bool throw_if_not_found=true) |
| void | setPath (std::string const &path) |
| std::filesystem::path | absolutePath (std::filesystem::path const &path="") |
Public Member Functions inherited from jevois::ParameterRegistry | |
| virtual | ~ParameterRegistry () |
Additional Inherited Members | |
Protected Member Functions inherited from jevois::Component | |
| virtual void | preInit () |
| virtual void | postInit () |
| virtual void | preUninit () |
| virtual void | postUninit () |
| virtual void | preInit () |
| virtual void | postInit () |
| virtual void | preUninit () |
| virtual void | postUninit () |
Protected Member Functions inherited from jevois::ParameterRegistry | |
| void | addParameter (ParameterBase *const param) |
| void | removeParameter (ParameterBase *const param) |
| void | callbackInitCall () |
Abstract base class for an object recognition component.
This base class provides a framework to recognize objects using deep neural networks. The network is implemented using the tiny-dnn library, see https://github.com/tiny-dnn/tiny-dnn
Derived classes implement a particular network by overriding the define() method of the base class. They also must implement the other abstract methods provided here.
To create a new object recognition component, one would usually derive from the ObjectRecognition class template as opposed to deriving directly from ObjectRecognitionBase.
Training is automatically launched if a pre-trained weight file is not found. Thus, typical workflow is, assuming JeVois v1.4 or later:
jevois-daemon on host, make sure it has write permission to the directory you created. It will fail to load the pre-trained weights and will initiate training.Starting with JeVois v1.5, tiny-dnn has been updated to a recent version which uses cereal as a back-end to save networks and weights. This yields efficient loading of pre-trained networks but the binary archive format is not portable between Intel x64 hosts and ARM platform. Hence, you should proceed as follows:
jevois-flash-card and you will avoid having to convert again next time JeVois starts. Definition at line 87 of file ObjectRecognition.H.
| typedef std::vector<tiny_dnn::float_t, tiny_dnn::aligned_allocator<tiny_dnn::float_t, 64> > ObjectRecognitionBase::vec_t |
Type used by tiny-dnn for the results:
Definition at line 91 of file ObjectRecognition.H.
| ObjectRecognitionBase::ObjectRecognitionBase | ( | std::string const & | instance | ) |
Constructor.
Definition at line 25 of file ObjectRecognition.C.
|
virtual |
Virtual destructor for safe inheritance.
Definition at line 30 of file ObjectRecognition.C.
|
pure virtual |
Return the name of a given category (0-based index in the vector of results)
Implemented in ObjectRecognitionCIFAR, ObjectRecognitionILAB, and ObjectRecognitionMNIST.
|
pure virtual |
Define the network structure.
Derived classes must implement this function and load a network structure.
Implemented in ObjectRecognitionCIFAR, ObjectRecognitionILAB, and ObjectRecognitionMNIST.
|
pure virtual |
Get the input size for the current network, useful to prepare inputs to process()
Implemented in ObjectRecognition< NetType >, and ObjectRecognition< tiny_dnn::sequential >.
|
pure virtual |
Process an image, results are confidence for each category.
Implemented in ObjectRecognition< NetType >, and ObjectRecognition< tiny_dnn::sequential >.
|
pure virtual |
Train the network.
Derived classes must implement this function.
Implemented in ObjectRecognitionCIFAR, ObjectRecognitionILAB, and ObjectRecognitionMNIST.