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

Background subtraction to detect moving objects. More...

Inheritance diagram for DemoBackgroundSubtract:
Collaboration diagram for DemoBackgroundSubtract:

Public Member Functions

 DemoBackgroundSubtract (std::string const &instance)
 Constructor. More...
 
virtual ~DemoBackgroundSubtract ()
 Virtual destructor for safe inheritance. More...
 
virtual void process (jevois::InputFrame &&inframe, jevois::OutputFrame &&outframe) override
 Processing function. More...
 
- Public Member Functions inherited from jevois::Module
 Module (std::string const &instance)
 
virtual ~Module ()
 
virtual void process (InputFrame &&inframe)
 
virtual void process (InputFrame &&inframe, GUIhelper &helper)
 
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)
 
- 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

jevois::Timer itsProcessingTimer
 
cv::Ptr< cv::BackgroundSubtractor > bgs
 

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

Background subtraction to detect moving objects.

This background subtraction algorithm learns, over time, a statistical model of the appearance of a scene when the camera is not moving. Any moving object entering the field of view will then be detected as significantly different from the learned pixel model.

You can thus use this module to detect moving objects with a static JeVois camera. This module is quite robust to image noise since it learns a statistical model of the distribution of "normal" values a pixel may take over time, as opposed to more simply subtracting one camera image from the previous one (which would be much noisier).

Trying it out

  • Make sure that your JeVois camera is stable and not moving (nor vibrating because of its fan); you may want to mount it securely using screws, zip ties, etc
  • When nothing moves, you should see the right side of the video progressively fade to black. This is the result of this module learning the normal range of RGB values that each pixel may take over time, given sensor noise, small variations in lighting, and other environmental factors.
  • Now move your hand or some other object in front of JeVois. It should be detected on the right side of the display and should show up in white color.
  • Note that the autogain and autoexposure features of the JeVois camera sensor may trip this model. For example if you suddenly present a large white object in front of the JeVois camera that had been looking at an overall dark scene for a while, that bright white object might trigger an automatic reduction in exposure, which will in turn brighten the whole image and make it appear much different from what it used to be (so, everything might briefly turn white color in the right panel of the video display). To avoid this, you may want to use this module with manual settings for gain, white balance, and exposure.

Note that this class has internal state (it learns the statistics of the background over time).

Author
Laurent Itti
Videomapping:
YUYV 640 240 15.0 YUYV 320 240 15.0 JeVois DemoBackgroundSubtract
Videomapping:
YUYV 320 120 30.0 YUYV 160 120 30.0 JeVois DemoBackgroundSubtract
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 79 of file DemoBackgroundSubtract.C.

Constructor & Destructor Documentation

◆ DemoBackgroundSubtract()

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

Constructor.

Definition at line 83 of file DemoBackgroundSubtract.C.

◆ ~DemoBackgroundSubtract()

virtual DemoBackgroundSubtract::~DemoBackgroundSubtract ( )
inlinevirtual

Virtual destructor for safe inheritance.

Definition at line 88 of file DemoBackgroundSubtract.C.

Member Function Documentation

◆ process()

Member Data Documentation

◆ bgs

cv::Ptr<cv::BackgroundSubtractor> DemoBackgroundSubtract::bgs
protected

Definition at line 180 of file DemoBackgroundSubtract.C.

Referenced by process().

◆ itsProcessingTimer

jevois::Timer DemoBackgroundSubtract::itsProcessingTimer
protected

Definition at line 179 of file DemoBackgroundSubtract.C.

Referenced by process().


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