JeVoisBase  1.20
JeVois Smart Embedded Machine Vision Toolkit Base Modules
Share this page:
Surprise Class Reference

Compute Itti & Baldi surprise over video frames. More...

#include <jevoisbase/Components/Saliency/Surprise.H>

Inheritance diagram for Surprise:
Collaboration diagram for Surprise:

Public Member Functions

 Surprise (std::string const &instance)
 Constructor. More...
 
 ~Surprise ()
 Virtual destructor for safe inheritance. More...
 
double process (jevois::RawImage const &input)
 Compute surprise from a YUYV video frame and return the surprise value in wows. More...
 
- 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
 
Engineengine () const
 
bool initialized () const
 
const std::string & className () const
 
const std::string & 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)
 
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)
 
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
 
Engineengine () const
 
bool initialized () const
 
const std::string & className () const
 
const std::string & 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)
 
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)
 
void setPath (std::string const &path)
 
std::filesystem::path absolutePath (std::filesystem::path const &path="")
 
- Public Member Functions inherited from jevois::ParameterRegistry
virtual ~ParameterRegistry ()
 

Protected Attributes

std::shared_ptr< SaliencyitsSaliency
 
std::vector< float > itsAlpha
 
std::vector< float > itsBeta
 

Related Functions

(Note that these are not member functions.)

 JEVOIS_DECLARE_PARAMETER (updatefac, float, "Surprise update factor on every video frame", 0.95F, jevois::Range< float >(0.001F, 0.999F), ParamCateg)
 Parameter. More...
 
 JEVOIS_DECLARE_PARAMETER (channels, std::string, "Channels to use for surprise computation: any combination of " "S (saliency), G (gist), C (color), I (intensity), O (orientation), F (flicker), and " "M (motion). Duplicate letters will be ignored.", "SCIOFMG", boost::regex("^[SCIOFMG]+$"), ParamCateg)
 Parameter. More...
 

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 ()
 

Detailed Description

Compute Itti & Baldi surprise over video frames.

This component detects surprising events in video frames using Itti & Baldi's Bayesian theory of surprise.

They defined surprise in a formal, quantitative manner (for the first time!), as follows: An observation is surprising if it significantly affects the internal (subjective) beliefs of an observer. For example, if I believe that there is a 10% chance of rain today (my prior belief), and then I look outside and I see only a few small scattered clouds, then I may still believe in that same 10% chance of rain (posterior belief after the observation). My observation was not surprising, and Itti & Baldi say that this is because it did not affect my beliefs. Formally, when my posterior beliefs after an observation are very similar to what my prior beliefs were before the observation, the observation carries no surprise. In contrast, if I see a sky covered with menacing dark clouds all over, I may revise my belief to a 80% chance of rain today. Because my posterior beliefs are now much different than my prior beliefs, the observation of clouds is said to carry a high surprise. Itti & Baldi further specify how to compute surprise by using Bayes' theorem to compute posterior beliefs in a pricipled way, and by using the Kullback-Leibler divergence to measure the difference between posterior and prior distributions of beliefs. This gives rise to a new quantitative measure of surprise, with a new unit, the 'wow' (one wow of surprise is experienced when your belief in something doubles).

For more information, check out L. Itti, P. F. Baldi, Bayesian Surprise Attracts Human Attention, Vision Research, Vol. 49, No. 10, pp. 1295-1306, May 2009.

In this component, we compute feature maps and a saliency map. These will provide some degree of invariance and robustness to noise, which will yield more stable overall results than if we were to compute surprise directly over RGB pixel values (see next point);

We then compute surprise in each pixel of each feature map. This is similar to what Itti & Baldi did but simplified to run in real time on the JeVois smart camera. Each pixel in each feature map will over time gather beliefs about what it usually 'sees' at that location in the video. When things change significantly and in a surprising way, that pixel will emit a local surprise signal. Because surprise is more complex than just computing an instantaneous difference, or measuring whether the current observation simply is an outlier to a learned distribution, it will be able to handle periodic motions (foliage in the wind, ripples on a body of water), periodic flickers (a constantly blinking light in the field of view), and noise.

This approach is related to [R. C. Voorhies, L. Elazary, L. Itti, Neuromorphic Bayesian Surprise for Far-Range Event Detection, In: Proc. 9th IEEE International Conference on Advanced Video and Signal-Based Surveillance (AVSS), Beijing, China, Sep 2012.](http://ilab.usc.edu/publications/doc/Voorhies_etal12avss.pdf).

Definition at line 75 of file Surprise.H.

Constructor & Destructor Documentation

◆ Surprise()

Surprise::Surprise ( std::string const &  instance)

Constructor.

Definition at line 21 of file Surprise.C.

References itsSaliency.

◆ ~Surprise()

Surprise::~Surprise ( )

Virtual destructor for safe inheritance.

Definition at line 28 of file Surprise.C.

Member Function Documentation

◆ process()

double Surprise::process ( jevois::RawImage const &  input)

Compute surprise from a YUYV video frame and return the surprise value in wows.

Definition at line 559 of file Surprise.C.

References itsSaliency.

Friends And Related Function Documentation

◆ JEVOIS_DECLARE_PARAMETER() [1/2]

JEVOIS_DECLARE_PARAMETER ( channels  ,
std::string  ,
"Channels to use for surprise computation: any combination of " "S   saliency,
G(gist)  ,
C(color)  ,
I(intensity)  ,
O(orientation)  ,
F(flicker)  ,
and " "M(motion). Duplicate letters will be ignored."  ,
"SCIOFMG"  ,
boost::regex("^[SCIOFMG]+$")  ,
ParamCateg   
)
related

Parameter.

◆ JEVOIS_DECLARE_PARAMETER() [2/2]

JEVOIS_DECLARE_PARAMETER ( updatefac  ,
float  ,
"Surprise update factor on every video frame"  ,
0.  95F,
jevois::Range< float >  0.001F, 0.999F,
ParamCateg   
)
related

Parameter.

Member Data Documentation

◆ itsAlpha

std::vector<float> Surprise::itsAlpha
protected

Definition at line 90 of file Surprise.H.

◆ itsBeta

std::vector<float> Surprise::itsBeta
protected

Definition at line 90 of file Surprise.H.

◆ itsSaliency

std::shared_ptr<Saliency> Surprise::itsSaliency
protected

Definition at line 89 of file Surprise.H.

Referenced by process(), and Surprise().


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