JeVoisBase  1.0
JeVois Smart Embedded Machine Vision Toolkit Base Modules
FaceDetector Class Reference

Face detection using OpenCV. More...

#include </lab/itti/jevois/software/jevoisbase/src/Components/FaceDetection/FaceDetector.H>

Inheritance diagram for FaceDetector:
Collaboration diagram for FaceDetector:

Public Member Functions

 FaceDetector (std::string const &instance)
 Constructor, loads the cascade classifiers from disk. More...
 
 ~FaceDetector ()
 Destructor. More...
 
void process (cv::Mat const &img, std::vector< cv::Rect > &faces, std::vector< std::vector< cv::Rect > > &eyes, bool detect_eyes=false)
 Process an image, results are held in our data members. More...
 
- 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 Member Functions

void postInit () override
 
- Protected Member Functions inherited from jevois::Component
virtual void preInit ()
 
virtual void preUninit ()
 
virtual void postUninit ()
 
virtual void preInit ()
 
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 ()
 

Protected Attributes

std::shared_ptr< cv::CascadeClassifier > itsFaceCascade
 
std::shared_ptr< cv::CascadeClassifier > itsEyesCascade
 

Related Functions

(Note that these are not member functions.)

#define JEVOIS_DECLARE_PARAMETER(ParamName, ParamType, ...)
 Parameter. More...
 
#define JEVOIS_DECLARE_PARAMETER(ParamName, ParamType, ...)
 Parameter. More...
 

Detailed Description

Face detection using OpenCV.

See tutorial at http://docs.opencv.org/trunk/d7/d8b/tutorial_py_face_detection.html

Definition at line 40 of file FaceDetector.H.

Constructor & Destructor Documentation

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

Constructor, loads the cascade classifiers from disk.

Definition at line 22 of file FaceDetector.C.

FaceDetector::~FaceDetector ( )

Destructor.

Definition at line 27 of file FaceDetector.C.

Member Function Documentation

void FaceDetector::postInit ( )
overrideprotectedvirtual

Reimplemented from jevois::Component.

Definition at line 31 of file FaceDetector.C.

References jevois::Component::absolutePath(), itsEyesCascade, itsFaceCascade, LFATAL, and LINFO.

void FaceDetector::process ( cv::Mat const &  img,
std::vector< cv::Rect > &  faces,
std::vector< std::vector< cv::Rect > > &  eyes,
bool  detect_eyes = false 
)

Process an image, results are held in our data members.

The given image should be grayscale and with histogram equalized, for example by doing:

// Given a color image in 'frame'
cv::Mat frame_gray;
cv::cvtColor(frame, frame_gray, CV_BGR2GRAY);
cv::equalizeHist(frame_gray, frame_gray);
// Then send frame_gray to FaceDetector::process()

If detect_eyes is true, throws if an eye cascade was not successfully loaded. Even if we do not detect eyes, the eyes vector will be resized to one (possibly empty) vector of eyes per face, so that it is safe to assume that one entry exists in eyes for each entry in faces.

Definition at line 50 of file FaceDetector.C.

References itsEyesCascade, and itsFaceCascade.

Friends And Related Function Documentation

#define JEVOIS_DECLARE_PARAMETER (   ParamName,
  ParamType,
  ... 
)
related

Parameter.

#define JEVOIS_DECLARE_PARAMETER (   ParamName,
  ParamType,
  ... 
)
related

Parameter.

Member Data Documentation

std::shared_ptr<cv::CascadeClassifier> FaceDetector::itsEyesCascade
protected

Definition at line 69 of file FaceDetector.H.

Referenced by postInit(), and process().

std::shared_ptr<cv::CascadeClassifier> FaceDetector::itsFaceCascade
protected

Definition at line 68 of file FaceDetector.H.

Referenced by postInit(), and process().


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