JeVoisBase  1.5
JeVois Smart Embedded Machine Vision Toolkit Base Modules
Share this page:
DarknetYOLO Class Reference

Detect multiple objects in scenes using the Darknet YOLO deep neural network. More...

Inheritance diagram for DarknetYOLO:
Collaboration diagram for DarknetYOLO:

Public Member Functions

 DarknetYOLO (std::string const &instance)
 Constructor. More...
 
virtual ~DarknetYOLO ()
 Virtual destructor for safe inheritance. More...
 
virtual void postUninit () override
 Un-initialization. More...
 
virtual void process (jevois::InputFrame &&inframe) override
 Processing function, no video output. More...
 
virtual void process (jevois::InputFrame &&inframe, jevois::OutputFrame &&outframe) override
 Processing function with video output to USB. More...
 
- Public Member Functions inherited from jevois::StdModule
 StdModule (std::string const &instance)
 
virtual ~StdModule ()
 
void sendSerialImg1Dx (unsigned int camw, float x, float size=0.0F, std::string const &id="", std::string const &extra="")
 
void sendSerialStd1Dx (float x, float size=0.0F, std::string const &id="", std::string const &extra="")
 
void sendSerialImg1Dy (unsigned int camh, float y, float size=0.0F, std::string const &id="", std::string const &extra="")
 
void sendSerialStd1Dy (float y, float size=0.0F, std::string const &id="", std::string const &extra="")
 
void sendSerialImg2D (unsigned int camw, unsigned int camh, float x, float y, float w=0.0F, float h=0.0F, std::string const &id="", std::string const &extra="")
 
void sendSerialStd2D (float x, float y, float w=0.0F, float h=0.0F, std::string const &id="", std::string const &extra="")
 
void sendSerialContour2D (unsigned int camw, unsigned int camh, std::vector< cv::Point_< T > > points, std::string const &id="", std::string const &extra="")
 
void sendSerialStd3D (float x, float y, float z, float w=0.0F, float h=0.0F, float d=0.0F, float q1=0.0F, float q2=0.0F, float q3=0.0f, float q4=0.0F, std::string const &id="", std::string const &extra="")
 
void sendSerialStd3D (std::vector< cv::Point3f > points, std::string const &id="", std::string const &extra="")
 
- Public Member Functions inherited from jevois::Module
 Module (std::string const &instance)
 
virtual ~Module ()
 
virtual void sendSerial (std::string const &str)
 
virtual void parseSerial (std::string const &str, std::shared_ptr< UserInterface > s)
 
virtual void supportedCommands (std::ostream &os)
 
 JEVOIS_DEFINE_ENUM_CLASS (SerStyle,(Terse)(Normal)(Detail)(Fine)) JEVOIS_DECLARE_PARAMETER(serstyle
 
 JEVOIS_DECLARE_PARAMETER (serprec, unsigned int, "Number of decimal points in standardized serial messages as " "defined in http://jevois.org/doc/UserSerialStyle.html", 0U, ParamCateg)
 
- Public Member Functions inherited from jevois::Component
 Component (std::string const &instance)
 
virtual ~Component ()
 
std::shared_ptr< ComponentgetSubComponent (std::string const &instance) const
 
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 &paramdescriptor, T const &val)
 
void setParamValUnique (std::string const &paramdescriptor, T const &val)
 
std::vector< std::pair< std::string, T > > getParamVal (std::string const &paramdescriptor) const
 
getParamValUnique (std::string const &paramdescriptor) const
 
std::vector< std::string > setParamString (std::string const &paramdescriptor, std::string const &val)
 
void setParamStringUnique (std::string const &paramdescriptor, std::string const &val)
 
std::vector< std::pair< std::string, std::string > > getParamString (std::string const &paramdescriptor) const
 
std::string getParamStringUnique (std::string const &paramdescriptor) const
 
void freezeParam (std::string const &paramdescriptor)
 
void unFreezeParam (std::string const &paramdescriptor)
 
void freezeAllParams ()
 
void unFreezeAllParams ()
 
std::string descriptor () const
 
void setParamsFromFile (std::string const &filename)
 
std::istream & setParamsFromStream (std::istream &is, std::string const &absfile)
 
void setPath (std::string const &path)
 
std::string absolutePath (std::string 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 &paramdescriptor, T const &val)
 
void setParamValUnique (std::string const &paramdescriptor, T const &val)
 
std::vector< std::pair< std::string, T > > getParamVal (std::string const &paramdescriptor) const
 
getParamValUnique (std::string const &paramdescriptor) const
 
std::vector< std::string > setParamString (std::string const &paramdescriptor, std::string const &val)
 
void setParamStringUnique (std::string const &paramdescriptor, std::string const &val)
 
std::vector< std::pair< std::string, std::string > > getParamString (std::string const &paramdescriptor) const
 
std::string getParamStringUnique (std::string const &paramdescriptor) const
 
void freezeParam (std::string const &paramdescriptor)
 
void unFreezeParam (std::string const &paramdescriptor)
 
void freezeAllParams ()
 
void unFreezeAllParams ()
 
std::string descriptor () const
 
void setParamsFromFile (std::string const &filename)
 
std::istream & setParamsFromStream (std::istream &is, std::string const &absfile)
 
void setPath (std::string const &path)
 
std::string absolutePath (std::string const &path="")
 
- Public Member Functions inherited from jevois::ParameterRegistry
virtual ~ParameterRegistry ()
 

Protected Attributes

std::shared_ptr< YoloitsYolo
 
std::future< float > itsPredictFut
 
cv::Mat itsRawInputCv
 
cv::Mat itsRawPrevOutputCv
 
cv::Mat itsNetInput
 
unsigned long itsFrame
 

Related Functions

(Note that these are not member functions.)

 JEVOIS_DECLARE_PARAMETER (netin, cv::Size, "Width and height (in pixels) of the neural network input layer, or [0 0] " "to make it match camera frame size.", cv::Size(0, 0), ParamCateg)
 Parameter. More...
 

Additional Inherited Members

- Protected Member Functions inherited from jevois::Component
virtual void preInit ()
 
virtual void postInit ()
 
virtual void preUninit ()
 
virtual void preInit ()
 
virtual void postInit ()
 
virtual void preUninit ()
 
- Protected Member Functions inherited from jevois::ParameterRegistry
void addParameter (ParameterBase *const param)
 
void removeParameter (ParameterBase *const param)
 
void callbackInitCall ()
 

Detailed Description

Detect multiple objects in scenes using the Darknet YOLO deep neural network.

Darknet is a popular neural network framework, and YOLO is a very interesting network that detects all objects in a scene in one pass. This module detects all instances of any of the objects it knows about (determined by the network structure, labels, dataset used for training, and weights obtained) in the image that is given to it.

See https://pjreddie.com/darknet/yolo/

This module runs a YOLO network and shows all detections obtained. The YOLO network is currently quite slow, hence it is only run once in a while. Point your camera towards some interesting scene, keep it stable, and wait for YOLO to tell you what it found.

Note that by default this module runs the Pascal-VOC version of tiny-YOLO, with these object categories:

  • aeroplane
  • bicycle
  • bird
  • boat
  • bottle
  • bus
  • car
  • cat
  • chair
  • cow
  • diningtable
  • dog
  • horse
  • motorbike
  • person
  • pottedplant
  • sheep
  • sofa
  • train
  • tvmonitor

Sometimes it will make mistakes! The performance of tiny-yolo-voc is about 57.1% correct (mean average precision) on the test set.

Speed and network size

The parameter netin allows you to rescale the neural network to the specified size. Beware that this will only work if the network used is fully convolutional (as is the case of the default tiny-yolo network). This not only allows you to adjust processing speed (and, conversely, accuracy), but also to better match the network to the input images (e.g., the defaultsize for tiny-yolo is 426x416, and, thus, passing it a input image of size 640x480 will result in first scaling that input to 416x312, then letterboxing it by adding grey borders on top and bottom so that the finaly input to the network is 416x416).

Here are expected processing speeds:

  • when netin = [0 0], proceses letterboxed 416x416 inputs, about 2450ms/image
  • when netin = [320 240], processes 320x240 inputs, about 1350ms/image
  • when netin = [160 120], processes 320x240 inputs, about 695ms/image

Serial messages

  • On every frame where detection results were obtained, this module sends a message
      DKY framenum
    where framenum is the frame number (starts at 0).
  • In addition, when detections are found which are above threshold, one message will be sent for each detected object (i.e., for each box that gets drawn when USB outputs are used), using a standardized 2D message:
    • Serial message type: 2D
    • id: the category name of the recognized object
    • x, y, or vertices: standardized 2D coordinates of object center or corners
    • w, h: standardized object size
    • extra: recognition score (in percent confidence)
Author
Laurent Itti
Display Name:
Darknet YOLO
Videomapping:
NONE 0 0 0.0 YUYV 640 480 0.4 JeVois DarknetYOLO
Videomapping:
YUYV 1280 480 15.0 YUYV 640 480 15.0 JeVois DarknetYOLO
Email:
itti@usc.edu
Address:
University of Southern California, HNB-07A, 3641 Watt Way, Los Angeles, CA 90089-2520, USA
Main URL:
http://jevois.org
Support URL:
http://jevois.org/doc
Other URL:
http://iLab.usc.edu
License:
GPL v3
Distribution:
Unrestricted
Restrictions:
None

Definition at line 120 of file DarknetYOLO.C.

Constructor & Destructor Documentation

◆ DarknetYOLO()

DarknetYOLO::DarknetYOLO ( std::string const &  instance)
inline

Constructor.

Definition at line 127 of file DarknetYOLO.C.

References itsYolo.

◆ ~DarknetYOLO()

virtual DarknetYOLO::~DarknetYOLO ( )
inlinevirtual

Virtual destructor for safe inheritance.

Definition at line 135 of file DarknetYOLO.C.

Member Function Documentation

◆ postUninit()

virtual void DarknetYOLO::postUninit ( )
inlineoverridevirtual

Un-initialization.

Reimplemented from jevois::Component.

Definition at line 141 of file DarknetYOLO.C.

References itsPredictFut.

◆ process() [1/2]

virtual void DarknetYOLO::process ( jevois::InputFrame &&  inframe)
inlineoverridevirtual

Processing function, no video output.

Reimplemented from jevois::Module.

Definition at line 149 of file DarknetYOLO.C.

References jevois::rawimage::convertToCvRGB(), jevois::RawImage::height, itsFrame, itsNetInput, itsYolo, LINFO, and jevois::RawImage::width.

◆ process() [2/2]

Friends And Related Function Documentation

◆ JEVOIS_DECLARE_PARAMETER()

JEVOIS_DECLARE_PARAMETER ( netin  ,
cv::Size  ,
"Width and height (in pixels) of the neural network input  layer,
or " "to make it match camera frame size."  [0 0],
cv::Size(0, 0)  ,
ParamCateg   
)
related

Parameter.

Member Data Documentation

◆ itsFrame

unsigned long DarknetYOLO::itsFrame
protected

Definition at line 342 of file DarknetYOLO.C.

Referenced by process().

◆ itsNetInput

cv::Mat DarknetYOLO::itsNetInput
protected

Definition at line 341 of file DarknetYOLO.C.

Referenced by process().

◆ itsPredictFut

std::future<float> DarknetYOLO::itsPredictFut
protected

Definition at line 338 of file DarknetYOLO.C.

Referenced by postUninit(), and process().

◆ itsRawInputCv

cv::Mat DarknetYOLO::itsRawInputCv
protected

Definition at line 339 of file DarknetYOLO.C.

Referenced by process().

◆ itsRawPrevOutputCv

cv::Mat DarknetYOLO::itsRawPrevOutputCv
protected

Definition at line 340 of file DarknetYOLO.C.

Referenced by process().

◆ itsYolo

std::shared_ptr<Yolo> DarknetYOLO::itsYolo
protected

Definition at line 337 of file DarknetYOLO.C.

Referenced by DarknetYOLO(), and process().


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