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

Object matching using OpenCV keypoint detection and matching. More...

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

Inheritance diagram for ObjectMatcher:
Collaboration diagram for ObjectMatcher:

Classes

struct  TrainData
 Training data structure for ObjectMatcher. More...
 

Public Member Functions

 ~ObjectMatcher ()
 Destructor. More...
 
double process (cv::Mat const &img, size_t &trainidx, std::vector< cv::Point2f > &corners)
 Process a greyscale image, returns match score, object index, and bounding box corners for best match object. More...
 
double process (cv::Mat const &img, size_t &trainidx)
 Process a greyscale image, returns match score, object index. More...
 
void postInit () override
 Load training images and compute keypoints and descriptors. More...
 
size_t numtrain () const
 Get number of training images. More...
 
void detect (cv::Mat const &img, std::vector< cv::KeyPoint > &keypoints)
 Detect keypoints. More...
 
void compute (cv::Mat const &img, std::vector< cv::KeyPoint > &keypoints, cv::Mat &descriptors)
 Compute descriptors for given keypoints. More...
 
double match (std::vector< cv::KeyPoint > const &keypoints, cv::Mat const &descriptors, size_t &trainidx, std::vector< cv::Point2f > &corners)
 Match given descriptors against those of our training images, return best match distance. More...
 
double match (std::vector< cv::KeyPoint > const &keypoints, cv::Mat const &descriptors, size_t &trainidx)
 Match given descriptors against those of our training images, return best match distance. More...
 
TrainData const & traindata (size_t idx) const
 Get the training data for a given index. 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 ()
 

Related Functions

(Note that these are not member functions.)

 JEVOIS_DECLARE_PARAMETER (hessian, double,"Hessian threshold", 800.0, ParamCateg)
 Parameter. More...
 
 JEVOIS_DECLARE_PARAMETER (traindir, std::string,"Directory where training images are","images", ParamCateg)
 Parameter. More...
 
 JEVOIS_DECLARE_PARAMETER (goodpts, jevois::Range< size_t >,"Number range of good matches considered", jevois::Range< size_t >(15, 100), ParamCateg)
 Parameter. More...
 
 JEVOIS_DECLARE_PARAMETER (distthresh, double,"Maximum distance for a match to be considered good", 0.2, ParamCateg)
 Parameter. More...
 

Additional Inherited Members

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

Detailed Description

Object matching using OpenCV keypoint detection and matching.

See tutorial at http://docs.opencv.org/3.0-beta/doc/py_tutorials/py_feature2d/py_surf_intro/py_surf_intro.html

Definition at line 46 of file ObjectMatcher.H.

Constructor & Destructor Documentation

ObjectMatcher::~ObjectMatcher ( )

Destructor.

Definition at line 35 of file ObjectMatcher.C.

Member Function Documentation

void ObjectMatcher::compute ( cv::Mat const &  img,
std::vector< cv::KeyPoint > &  keypoints,
cv::Mat &  descriptors 
)

Compute descriptors for given keypoints.

Note
keypoints is an input argument but opencv wants a non-const ref to it for some reason.

Definition at line 117 of file ObjectMatcher.C.

Referenced by process().

void ObjectMatcher::detect ( cv::Mat const &  img,
std::vector< cv::KeyPoint > &  keypoints 
)

Detect keypoints.

Definition at line 111 of file ObjectMatcher.C.

Referenced by process().

double ObjectMatcher::match ( std::vector< cv::KeyPoint > const &  keypoints,
cv::Mat const &  descriptors,
size_t &  trainidx,
std::vector< cv::Point2f > &  corners 
)

Match given descriptors against those of our training images, return best match distance.

Definition at line 123 of file ObjectMatcher.C.

References LFATAL.

Referenced by process().

double ObjectMatcher::match ( std::vector< cv::KeyPoint > const &  keypoints,
cv::Mat const &  descriptors,
size_t &  trainidx 
)

Match given descriptors against those of our training images, return best match distance.

Definition at line 164 of file ObjectMatcher.C.

References LFATAL.

size_t ObjectMatcher::numtrain ( ) const

Get number of training images.

Definition at line 304 of file ObjectMatcher.C.

void ObjectMatcher::postInit ( )
overridevirtual
double ObjectMatcher::process ( cv::Mat const &  img,
size_t &  trainidx,
std::vector< cv::Point2f > &  corners 
)

Process a greyscale image, returns match score, object index, and bounding box corners for best match object.

If return value is 1.0e30, then no good object match was found. This runs detect(), then compute() and then match(). One may also want to run those separately in some cases.

Definition at line 87 of file ObjectMatcher.C.

References compute(), detect(), and match().

double ObjectMatcher::process ( cv::Mat const &  img,
size_t &  trainidx 
)

Process a greyscale image, returns match score, object index.

If return value is 1.0e30, then no good object match was found. This runs detect(), then compute() and then match(). One may also want to run those separately in some cases.

Definition at line 99 of file ObjectMatcher.C.

References compute(), detect(), and match().

ObjectMatcher::TrainData const & ObjectMatcher::traindata ( size_t  idx) const

Get the training data for a given index.

Definition at line 297 of file ObjectMatcher.C.

References LFATAL.

Friends And Related Function Documentation

JEVOIS_DECLARE_PARAMETER ( hessian  ,
double  ,
"Hessian threshold"  ,
800.  0,
ParamCateg   
)
related

Parameter.

JEVOIS_DECLARE_PARAMETER ( traindir  ,
std::string  ,
"Directory where training images are"  ,
"images"  ,
ParamCateg   
)
related

Parameter.

JEVOIS_DECLARE_PARAMETER ( goodpts  ,
jevois::Range< size_t >  ,
"Number range of good matches considered"  ,
jevois::Range< size_t >  15, 100,
ParamCateg   
)
related

Parameter.

JEVOIS_DECLARE_PARAMETER ( distthresh  ,
double  ,
"Maximum distance for a match to be considered good"  ,
0.  2,
ParamCateg   
)
related

Parameter.


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